#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:64000000")
int n, m, i, j, u, v, w, k;
const int maxn = 18;
const int maxm = 110;
const int maxmask = (1 << maxn) - 1;
const int infi = 1e9 + 7;
const long long mod = 1e9;
const long long infl = 1e18 + 7;
const double eps = 1e-9;
string ar;
bool check(int r) {
  int l = 0, a = 0;
  for (int i = 0; i < ar.size() - 1; ++i) {
    if (ar[i] == 'R') {
      ++a;
      a = min(a, r - 1);
    } else {
      --a;
    }
    l = min(a, l);
  }
  --a;
  if (a < l) {
    return 1;
  }
  return 0;
}
int main() {
  cin >> ar;
  if (ar[ar.size() - 1] == 'R') {
    for (i = 0; i < ar.size(); ++i) {
      if (ar[i] == 'R') {
        ar[i] = 'L';
      } else {
        ar[i] = 'R';
      }
    }
  }
  if (check(1001000)) {
    cout << 1;
    return 0;
  }
  int l = 1, r = 1000100, m, res = 0;
  while (l <= r) {
    m = (l + r) >> 1;
    if (check(m)) {
      res = m;
      l = m + 1;
    } else {
      r = m - 1;
    }
  }
  cout << res;
  return 0;
}
