#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
char str[N], last;
int len;
bool check(int n) {
  int pos = 0, minp = 0;
  for (int i = 0; i < len; i++) {
    minp = min(minp, pos);
    if (str[i] == last)
      pos--;
    else
      pos++;
    if (pos == n) pos--;
  }
  return pos < minp;
}
int main() {
  while (~scanf("%s", str)) {
    len = strlen(str);
    last = str[len - 1];
    int l = 1, r = len, m;
    while (l <= r) {
      m = (l + r) >> 1;
      if (check(m))
        l = m + 1;
      else
        r = m - 1;
    }
    printf("%d\n", r == len ? 1 : r);
  }
  return 0;
}
