#include<iostream>
#include<string>
using namespace std;
string S;
int main() {
	cin >> S;
	int cnt = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'I' && cnt % 2 == 0) {
			cnt++;
		}
		else if (S[i] == 'O' && cnt % 2 == 1) {
			cnt++;
		}
	}
	if (cnt % 2 == 0 && cnt >= 1) { cnt--; }
	cout << cnt << endl;
	return 0;
}