#include <bits/stdc++.h>
using namespace std;
using ii = pair<int, int>;
using ll = long long;
using db = long double;
using mat = vector<vector<int>>;
const int mod = 1e9 + 7;
const int N = 1e6 + 5;
char str[N];
int n;
bool check(int x) {
  int ptr = 0, mn = 0;
  if (x == 0) return 0;
  for (int i = 0; i < n; i++) {
    mn = min(mn, ptr);
    if (str[i] == str[n - 1])
      --ptr;
    else
      ++ptr;
    if (ptr == x) --ptr;
  }
  return ptr < mn;
}
int main() {
  scanf("%s", str);
  n = strlen(str);
  int lo = 0, hi = n;
  while (lo < hi) {
    int md = lo + (hi - lo + 1) / 2;
    if (check(md))
      lo = md;
    else
      hi = md - 1;
  }
  if (lo == n) lo = 1;
  cout << lo << '\n';
  return 0;
}
