#include <bits/stdc++.h>
using namespace std;
char s[1000010];
int n;
bool check(int len) {
  int now = 0, lft = 0;
  bool flag = 1;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'R') {
      flag = 0;
      if (now + 1 != len) now++;
    } else
      now--;
    if (now < lft) {
      lft = now;
      flag = 1;
    }
  }
  return flag;
}
int main() {
  scanf("%s", s);
  n = strlen(s);
  if (s[n - 1] == 'R') {
    for (int i = 0; i < n; i++) {
      if (s[i] == 'R')
        s[i] = 'L';
      else
        s[i] = 'R';
    }
  }
  if (check(n + 5)) {
    puts("1");
    return 0;
  }
  int l = 0, r = n + 5, ret = 0;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (check(mid))
      ret = mid, l = mid + 1;
    else
      r = mid - 1;
  }
  printf("%d\n", ret);
  return 0;
}
