#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define SZ(X) ((int)(X).size())
#define endl "\n";
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
    int n,a[9]={111,222,333,444,555,666,777,888,999};
    cin>>n;
    for(int i=0;i<9;i++){
    	if(n<=a[i]) {
	cout<<a[i]<<endl;
	return 0;
	}
		
    }
    
    


    
    

   	

   return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(int)(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

int main()
{
  string x; cin>>x;

  int s=0;
  int t=0;
  for (auto c:x) {
    if (c == 'S') {
      s++;
    } else {
      if (s > 0) s--;
      else t++;
    }
  }
  cout << t+s << endl;

  return 0;
}
