#include <bits/stdc++.h>
using namespace std;
string a;
int n;
inline int pd(int x) {
  int now = 0, mx = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] == 'L') --now;
    if (a[i] == 'R') ++now;
    now = max(now, x + 1);
    if (i == n && now <= mx) return 0;
    mx = max(mx, now);
  }
  return 1;
}
int main(int argc, char** argv) {
  cin >> a;
  n = a.size();
  a = ' ' + a;
  if (a[n] == 'L') {
    for (int i = 1; i <= n; i++)
      if (a[i] == 'L')
        a[i] = 'R';
      else
        a[i] = 'L';
  }
  if (pd(-10000000)) {
    cout << 1;
    return 0;
  }
  int l = -10000000, r = -1, ans = 0;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (pd(mid))
      ans = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  cout << -ans;
  return 0;
}
