#include <bits/stdc++.h>
using namespace std;
int n;
char s[1000100];
bool go(int x) {
  int r = 0;
  int p = 0;
  x++;
  for (int i = 0; i < n - 1; i++) {
    if (p > x)
      p = (s[i] == 'L' ? p - 1 : p + 1);
    else if (s[i] == 'R')
      p = p + 1;
    if (r < p) r = p;
  }
  if (r < p + 1)
    return true;
  else
    return false;
}
int main() {
  scanf("%s", s);
  n = strlen(s);
  if (s[n - 1] == 'L')
    for (int i = 0; i < n; i++) s[i] = s[i] == 'L' ? 'R' : 'L';
  int l = 0, r = -n - 1;
  bool use = true;
  for (int i = 0; i < n; i++)
    if (s[i] == 'L') use = false;
  if (use || go(-1000000000)) {
    cout << 1;
    return 0;
  }
  while (l > r + 1) {
    int m = (l + r) / 2;
    if (go(m))
      l = m;
    else
      r = m;
  }
  cout << l * (-1);
  return 0;
}
