#include <bits/stdc++.h>
using namespace std;
long long n, l, r;
string s;
inline long long read() {
  long long sum = 0, x = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') x = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    sum = sum * 10 + ch - '0';
    ch = getchar();
  }
  return sum * x;
}
inline void write(long long x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
  return;
}
inline bool check(long long z) {
  long long x = 0, y = 0;
  bool t = 1;
  for (register long long i = 0; s[i]; ++i) {
    if (s[i] == 'R') {
      t = 0;
      if (x + 1 != z) ++x;
    } else
      --x;
    if (x < y) {
      y = x;
      t = 1;
    }
  }
  return t;
}
signed main() {
  cin >> s;
  n = s.size();
  if (s[n - 1] == 'R')
    for (register long long i = 0; s[i]; ++i)
      if (s[i] == 'R')
        s[i] = 'L';
      else
        s[i] = 'R';
  if (check(n + 5)) {
    write(1);
    return 0;
  }
  r = n + 5;
  while (l < r) {
    long long mid = (l + r + 1) >> 1;
    if (check(mid))
      l = mid;
    else
      r = mid - 1;
  }
  write(l);
  return 0;
}
