#include <bits/stdc++.h>
using namespace std;
int n;
char s[1000005];
bool check(int x) {
  int p = 0, lst = 0;
  bool flag = 1;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'R') {
      flag = 0;
      if (p + 1 != x) p++;
    } else
      p--;
    if (p < lst) {
      lst = p;
      flag = 1;
    }
  }
  return flag;
}
int main() {
  scanf("%s", s);
  n = strlen(s);
  if (s[n - 1] == 'R') {
    for (int i = 0; s[i]; 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;
  while (l < r) {
    int mid = (l + r + 1) / 2;
    if (check(mid))
      l = mid;
    else
      r = mid - 1;
  }
  printf("%d", l);
  return 0;
}
