#include <iostream>
#include <string>

using namespace std;

int main() {
	string s; cin >> s;
	int ans = 0, now = 0;
	for (int i = 0; i < s.size(); ++i) {
		if (s[i] == 'R') now++;
		else now--;
		if (now == 4) ans++, now = 0;
		else if (now == -4) now = 0;
	}
	cout << ans << endl;

	return 0;
}
