//・Except for the beginning and the end of special commands, Gururin does not face north.
//より、現在向いている方向northで文字列を分けるとよさそう。計算量の工夫はいらない。
#include <iostream>
#include <string>
#include <vector>
using namespace std;

string s;
vector<int> t;

int main() {
	int i, j;
	int dir = 0;
	
	cin >> s;
	for (i = 0; i < s.length(); i++) {
		if (dir == 0) t.push_back(i);
		if (s[i] == 'R') dir = (dir + 1) % 4;
		else dir = (dir + 3) % 4;
	}
	if (dir == 0) t.push_back(i);
	
	int ans = 0;
	for (i = 0; i < (int)t.size() - 1; i++) {
		bool used[4] = {false};
		dir = 0;
		for (j = t[i]; j < t[i + 1]; j++) {
			if (s[j] == 'R') {
				dir = (dir + 1) % 4;
				used[dir] = true;
			}
			else { dir = (dir + 3) % 4; }
		}
		for (j = 0; j < 4; j++) if (!used[j]) break;
		if (j == 4) ans++;
	}
	
	cout << ans << endl;
	return 0;
}
