#include <bits/stdc++.h>

using namespace std;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int c = 0, ans = 0;
  bool f = true;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'R') {
      c++;
      if (c == 4) {
        if (f) ans++;
        c = 0;
        f = true;
      }
    }
    if (s[i] == 'L') {
      c--;
      if (c < 0) {
        c = 3;
        f = false;
      }
    }
    if (c == 0) f = true;
  }
  cout << ans << endl;

  return 0;
}
