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

int main()
{
    string str;

    cin >> str;

    int cnt = 0, sum = 0;
    for( int i = 0; i < str.size(); i++ )
    {
        if( str[i] == 'R' )
            cnt++;
        else
            cnt--;
        if( cnt == 4 )
        {
            sum++;
            cnt = 0;
        }
        if( cnt == -4 )
            cnt = 0;
    }

    cout << sum << endl;

    return 0;
}
