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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i < b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const long double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	string s;
	cin >> s;

	cout << s.substr(0, s.length() - 8) << endl;

	return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int ans=0;
  for(int i=0;i<s.size();i++){
    if(s[i]!='J') continue;
    else{
      int now=i+1;
      int J=1,O=0,I=0;
      int flag1=1,flag2=0;
      while(s[now]=='J'){
	//cout<<now<<endl;
	J++;
	now++;
      }
      while(s[now]=='O' && flag1){
	//cout<<now<<endl;
	O++;
	now++;
	flag2=1;
      }
      if(J<O){
	i=now-1;
	continue;
      }
      while(s[now]=='I' && flag2){
	//cout<<now<<endl;
	I++;
	now++;
      }
      if(O>I){
	i=now-1;
	continue;
      }
      ans=max(ans,min(I,min(O,J)));
      // cout<<ans<<endl;
      i=now-1;
      //cout<<i<<endl;
      //cout<<s[i]<<endl;
    }
  }
  cout<<ans<<endl;
  return 0;
}
	  