#include <bits/stdc++.h>
using namespace std;
string str;
int n;
bool solve(int x) {
  int i, now = 0, left = 0;
  for (i = 0; i < n; i++) {
    if (str[i] == 'L') {
      now--;
      if (i == n - 1) {
        if (now < left) return true;
        return false;
      }
      if (now < left) left = now;
    } else {
      if (now + 1 < x) now++;
    }
  }
}
int main() {
  int i, l, r, m;
  while (cin >> str) {
    n = str.size();
    if (str[n - 1] == 'R') {
      for (i = 0; i < n; i++) {
        if (str[i] == 'L')
          str[i] = 'R';
        else
          str[i] = 'L';
      }
    }
    if (solve(n)) {
      printf("1\n");
      continue;
    }
    l = 0;
    r = n - 1;
    while (l < r) {
      m = (l + r + 1) / 2;
      if (solve(m))
        l = m;
      else
        r = m - 1;
    }
    cout << l << endl;
  }
  return 0;
}
