#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin>>s;
    int degree=0,count=0;
    for (int i=0;i<s.size();i++) {
        if (s[i]=='R') {
            degree+=90;
        } else {
            degree-=90;
        }
        if (degree==360) {
            count++;
            degree=0;
        } else if (degree==-360) {
            degree=0;
        }
    }
    cout<<count<<endl;
}
