#include<string>
#include<iostream>
#include<vector>
using namespace std;

signed main(){
  const int MAX = 9;

  vector<int> con(MAX);
  int now = 4;
  int ans = 0;
  string s;

  cin>>s;

  con[now] = true;

  for(int i = 0; i < s.size(); i++){

    if(s[i] == 'R') {
      now++;
    } else {
      now--;
    }
    con[now] = !con[now];

    if(now == 0) {

      for(int i = 0; i < MAX; i++){
        con[i] = 0;
      }

      now = 4;

      con[now] = true;
    } else if(now == 8) {

      for(int i = 0; i < MAX; i++){
        con[i] = 0;
      }

      now = 4;

      ans++;

      con[now] = true;
    }
  }

  cout<<ans<<endl;

  return 0;
}

