#include <bits/stdc++.h>
using namespace std;
char z, s[1000100];
int len, l, r, mid;
bool ck(int n) {
  int i, pos = 0, minp = 0;
  for (i = 1; i <= len; i++) {
    minp = min(minp, pos);
    if (s[i] == z)
      pos--;
    else
      pos++;
    if (pos == n) pos--;
  }
  return pos < minp;
}
int main() {
  int ans = 0;
  scanf("%s", s + 1);
  r = len = strlen(s + 1);
  z = s[r];
  l = 1;
  r = len;
  while (l <= r) {
    mid = (l + r) >> 1;
    if (!ck(mid))
      r = mid - 1;
    else {
      l = mid + 1;
      ans = mid;
    }
  }
  printf("%d\n", (r == len) ? 1 : ans);
  return 0;
}
