#include<bits/stdc++.h>
using namespace std;

int main() {
    string s;
    cin >> s;
    int ans = 0, dir = 0;
    for (char c : s) {
        if (c == 'R') ++dir;
        else --dir;

        if (dir == 4) {
            ++ans;
            dir = 0;
        }
        else if (dir == -4) dir = 0;
    }
    cout << ans << "\n";
    return 0;
}

