#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e6;
int N;
char C[MAXN];
bool R[MAXN];
int curPos[MAXN];
int minPos[MAXN];
long long go() {
  for (int i = 0; i < N; i++) {
    R[i] = C[i] == C[N - 1];
  }
  curPos[0] = 0;
  minPos[0] = 0;
  for (int i = 0; i < N; i++) {
    if (R[i])
      curPos[i + 1] = curPos[i] + 1;
    else
      curPos[i + 1] = curPos[i] - 1;
    minPos[i + 1] = min(minPos[i], curPos[i + 1]);
  }
  int len = curPos[N] - minPos[N];
  bool good = true;
  for (int i = 0; i < N; i++) {
    if (curPos[i] >= curPos[N]) good = false;
  }
  if (good) return 1;
  good = true;
  for (int i = 0; i < N; i++) {
    if (curPos[i] - minPos[i] < curPos[N] - minPos[N])
      ;
    else
      return 0;
  }
  int obsPos = -N - 1;
  for (int i = 0; i < N; i++) {
    obsPos = max(obsPos, curPos[i] - (curPos[N] - minPos[N]));
  }
  return -obsPos;
}
int main() {
  cin >> C;
  N = strlen(C);
  cout << go() << '\n';
  return 0;
}
