#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  char c;
  bool d[(int)1e6], v;
  int n = 0, i = 0, t, p, m;
  while (cin >> c) d[n++] = c - 'L';
  for (; !d[n - 1] && i < n; i++) d[i] ^= 1;
  long long l = 0, r = n + 1;
  do
    for (t = 0, p = 0, m = (l + r + 1) >> 1, i = 0; i < n; v = 0,
        d[i++]                                                          ? t++
                                                           : t - 1 > -m ? t--
                                                                        : 0,
        t > p ? p = t, v = 1 : 0)
      ;
  while (l < r && (v ? l = m : r = m - 1));
  cout << (l == n + 1 ? 1 : l);
}
