#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e6 + 10;
char str[MAX];
int check(int x, int n) {
  int step = 0;
  int mstep = 0;
  for (int i = 0; i < n; i++) {
    if (str[i] == 'R' && step + 1 != x)
      step++;
    else if (str[i] == 'L')
      step--;
    if (i < n - 1) mstep = min(mstep, step);
  }
  return step < mstep;
}
int main() {
  scanf("%s", str);
  int n = strlen(str);
  if (str[n - 1] == 'R')
    for (int i = 0; i < n; i++)
      if (str[i] == 'R')
        str[i] = 'L';
      else
        str[i] = 'R';
  if (check(MAX, n))
    printf("1\n");
  else {
    int L = 1, R = n;
    int ans = 0;
    while (L <= R) {
      int mid = (L + R) >> 1;
      if (check(mid, n))
        ans = mid, L = mid + 1;
      else
        R = mid - 1;
    }
    printf("%d\n", ans);
  }
  return 0;
}
