#include<bits/stdc++.h>
using namespace std;
 
#define INF (1<<28)
#define DEKAI 1000000007
#define FDST int hogehoge;cin>>hogehoge;
 
 
int main(){
  string s;
  int p=0,ans=0;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='R') p++;
    if(s[i]=='L') p--;
    if(p==4){
      ans++;
      p=0;
    }
    if(p==-4) p=0;
  }
  cout<<ans<<endl;
  return 0;
}
