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