#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:36777216")
using namespace std;
char ch[1111111];
int n;
bool check(int pos) {
  int now = 0, mx = 0;
  for (int i = 0; i < n; i++) {
    if (ch[i] == 'R' && now == pos - 1) continue;
    if (ch[i] == 'R')
      now++;
    else
      now--;
    if (i == n - 1) return now < mx;
    if (now < mx) mx = now;
  }
}
int main() {
  scanf(" %s", &ch);
  n = strlen(ch);
  if (ch[n - 1] == 'R')
    for (int i = 0; i < n; i++)
      if (ch[i] == 'R')
        ch[i] = 'L';
      else
        ch[i] = 'R';
  check(4);
  if (check(2 * n)) {
    cout << 1 << endl;
    return 0;
  }
  int l = 1, r = n;
  while (l < r) {
    int mid = l + r + 1 >> 1;
    if (check(mid))
      l = mid;
    else
      r = mid - 1;
  }
  if (r == 1)
    cout << check(1) << endl;
  else
    cout << r << endl;
}
