#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int n;
string s;
bool check(int x) {
  int cur = 0, l = 0;
  for (int i = 0; i < n - 1; i++) {
    cur += (s[i] == 'R') ? 1 : -1;
    if (cur == x) cur--;
    l = min(l, cur);
  }
  return cur == l;
}
int main() {
  cin >> s;
  n = s.size();
  if (s[n - 1] == 'R')
    for (int i = 0; i < n; i++) s[i] = (s[i] == 'R') ? 'L' : 'R';
  int l = 0, r = INF + 1;
  while (r - l > 1) {
    int m = (l + r) / 2;
    if (check(m))
      l = m;
    else
      r = m;
  }
  cout << (l == INF ? 1 : l);
  return 0;
}
