#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
#include<array>

#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define all(v) (v).begin(),(v).end()
#define all_rev(v) (v).rbegin(),(v).rend()
#define debug(x) cout << #x << ": " << x << '\n';
#define degreeToRadian(deg) (((deg)/360)*2*M_PI)
#define radianTodegree(rad) (((rad)/2/M_PI)*360)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
using ll = long long;
using P = pair<int,int>;
using PL = pair<ll, ll>;
const ll INF = 1LL<<60;
const int MOD = 1e9 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  //cin.tie(0);ios::sync_with_stdio(false);
  //cout << fixed << setprecision(15);
  
  int n;
  string s;
  cin >> n >> s;

  int ans = n;
  stack<char> st;

  for (int i = 0; i < s.size(); i++) {
    st.push(s[i]);

    if (st.size() > 2) {
      string t = "";
      rep (j, 3) {
        t += st.top();
        st.pop();
      }

      if (t == "xof") ans -= 3;
      else rep (j, 3) st.push(t[2 - j]);
    }
  }

  cout << ans << endl;
  return 0;
}

#include <iostream>
#include <vector>
//#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MOD 998244353
//#define MAX 100100
//#define NIL -1
//#define INFTY 1000000000000000000

int main(){
    LL n;
    LL k;
    cin >> n >> k;
    vector<vector<LL>> t(n, vector<LL>(n));
    for(LL i=0; i<n; i++){
        for(LL j=0; j<n; j++){
            cin >> t[i][j];
        }
    }
    vector<LL> v(n-1);
    for(LL i=0; i<n-1; i++){
        v[i]=i+1;
    }

    LL sum_val;
    LL ans=0;
    do{
        sum_val=t[0][v[0]];
        for(LL i=0; i<n-2; i++){
            //cout << v[i] << endl;
            sum_val+=t[v[i]][v[i+1]];
        }
        sum_val+=t[v[n-2]][0];
        //cout << sum_val << endl;
        if(sum_val==k){
            ans++;
        }
    }while(next_permutation(v.begin(), v.end()));

    cout << ans << endl;

    return 0;
}
