#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int ans = 0;
  int n = s.size();
  int dir = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'R') {
      dir++;
    } else {
      dir--;
    }
    if (dir == -4)
      dir = 0;
    if (dir == 4) {
      dir = 0;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
