#include <bits/stdc++.h>
const int MAXN = 1100000;
char s[MAXN];
int n;
bool check(int o) {
  int p = 0;
  int mx = 0;
  bool uni = true;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'L')
      p--;
    else {
      if (p < o - 1) p++;
    }
    if (p < mx) {
      mx = p;
      uni = true;
    } else {
      uni = false;
    }
  }
  return uni;
}
int main() {
  scanf("%s", s);
  n = strlen(s);
  if (s[n - 1] == 'R') {
    for (int i = 0; i < n; i++) {
      s[i] = (s[i] == 'L') ? 'R' : 'L';
    }
  }
  if (check(n + 1)) {
    printf("1");
    return 0;
  }
  int a = 1, b = n;
  while (a <= b) {
    int m = (a + b) / 2;
    if (check(m)) {
      a = m + 1;
    } else {
      b = m - 1;
    }
  }
  printf("%d", a - 1);
}
