#include <bits/stdc++.h>
using namespace std;
#define rep(i,i1,n) for(int i=(int)(i1);i<(int)(n);i++)
#define ll long long
#define vi vector<int>
#define vll vector<long long>
using graph = vector<vector<int>>;

int main() {
  string s;
  cin>>s;
  int count=0;
  
  rep(i,0,9){
    if(s.at(i)=='Z'&&s.at(i+1)=='O'&&s.at(i+2)=='N'&&s.at(i+3)=='e'){
      count++;
    }
  }
  cout<<count;
}
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define V vector
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define sz(x) int(x.size())
#define pcnt __builtin_popcountll
template <typename T> bool chmin(T &a, const T &b) {if(a > b){a = b; return true;} return false;}
template <typename T> bool chmax(T &a, const T &b) {if(a < b){a = b; return true;} return false;}
template <typename T> void print(T a) {cout << a << ' ';}
template <typename T> void printe(T a) {cout << a << endl;}
template <typename T> void printv(T a) {rep(i, sz(a))print(a[i]); cout<<endl;}
template <typename T> void printp(pair<T, T> a) {print(a.first); cout<<a.second<<endl;}
template <typename A, size_t N, typename T> void Fill (A (&array)[N], const T & val) {fill ((T*)array, (T*)(array+N), val);}
template <typename T> using vc = vector<T>;
template <typename T> using vv = vc<vc<T>>;
template <typename T> using vvv = vc<vv<T>>;
using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using vi = vc<int>;
using vvi = vv<int>;
using vl = vc<ll>;
using vvl = vv<ll>;
vi di = {-1, 1,  0, 0, -1, -1,  1, 1};
vi dj = { 0, 0, -1, 1, -1,  1, -1, 1};

int main () {
    int n; cin >> n;
    int m = 5;
    vvi a(n, vi(m)); rep(i, n) rep(j, m) cin >> a[i][j];
    vi MX(m, 0);
    rep(i, n) rep(j, m) chmax(MX[j], a[i][j]);
    int ans = 0;
    rep(i, n) {
        rep(j, i) {
            vi mx(m); // i,jさんの最大値
            rep(k, 5) mx[k] = max(a[i][k], a[j][k]);
            int mn = 2e9, im = -1;
            rep(k, 5) if (chmin(mn, mx[k])) im = k;
            mx[im] = MX[im];
            int res = 2e9;
            rep(k, 5) chmin(res, mx[k]);
            chmax(ans, res);
        }
    }
    cout << ans << endl;
    return 0;
}