#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
int n;
int m;
string s;
int good(int h) {
  int x = 0, y = 0;
  for (int i = 0; i < n - 1; i++) {
    if (s[i] == 'L' && x - 1 > -h)
      x--;
    else if (s[i] == 'R')
      x++;
    y = max(y, x);
  }
  return int(x == y);
}
int main() {
  cin >> s;
  n = ((int)(s).size());
  if (s[((int)(s).size()) - 1] == 'L')
    for (int i = 0; i < ((int)(s).size()); i++)
      if (s[i] == 'L')
        s[i] = 'R';
      else
        s[i] = 'L';
  if (good(1e9))
    printf("1\n");
  else {
    int l = 0, r = 1e9;
    while (r - l > 1) {
      int s = (l + r) / 2;
      if (good(s))
        l = s;
      else
        r = s;
    }
    printf("%d\n", l);
  }
  return 0;
}
