#include <bits/stdc++.h>
using namespace std;
char c[1000005];
int n;
bool check(int x) {
  int now = 0, Min = 0;
  for (int i = 1; i < n; i++) {
    if (c[i] == 'R') {
      if (now + 1 < x) now++;
    } else
      now--;
    Min = min(Min, now);
  }
  if (now - 1 < Min)
    return true;
  else
    return false;
}
int main() {
  scanf("%s", c + 1);
  n = strlen(c + 1);
  int now = 0;
  int l = 0, r = n, sum1 = 0;
  int tmp;
  if (c[n] == 'R')
    for (int i = 1; i <= n; i++) c[i] = 'L' + 'R' - c[i];
  if (check(n + 1)) {
    puts("1");
    return 0;
  }
  while (l < r) {
    int mid = (l + r + 1) >> 1;
    if (check(mid))
      l = mid;
    else
      r = mid - 1;
  }
  printf("%d\n", l);
  return 0;
}
