#include<bits/stdc++.h>
using namespace std;
#define int long long
#define loop(i, start, end) for (int i = start; i <= end; i++)
#define rloop(i, start, end) for (int i = start; i >= end; i--)
#define vi vector<int>
#define vec(x) vector<x>
#define sz(v) (int)v.size() 
#define UB upper_bound
#define LB lower_bound
#define all(v) (v).begin(),(v).end()
#define arl(v) (v).rbegin(),(v).rend()
#define fsp(a) fixed<<setprecision(a)
#define mem(a,with) memset(a, with, sizeof (a))
#define vmn(a) (*min_element(a.begin(),a.end()))   
#define vmx(a) (*max_element(a.begin(),a.end()))
#define bs(a,key) binary_search(all(a),key)    /// return bool.
#define rotl(a,x) rotate(a.begin(),a.begin()+x,a.end());
#define rotr(a,x) rotl(a,a.size()-x);
#define nl cout<<endl
#define dbg(x) cerr << #x << " :: " << x << endl;
#define dbg2(x, y) cerr << #x << " :: " << x << "\t" << #y << " :: " << y << endl;
#define MOD 1000000007
int add(int x, int y) {int res = x + y; return (res >= MOD ? res - MOD : res);}
int mul(int x, int y) {int res = x * y; return (res >= MOD ? res % MOD : res);}
int power(int x, int y) {int res = 1; x %= MOD; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}

void solve(){
    //code goes here
    int n,k;
    cin>>n>>k;
    vec(vi) cost(n+1,vi(n+1,0));
    loop(i,1,n){
        loop(j,1,n) cin>>cost[i][j];
    }

    vi arr;
    int ans=0;
    loop(i,2,n) arr.push_back(i);
    do{
        int i=0,sum=0;
        int l=1,r=arr[i];
        while(i<arr.size()){
            sum+=cost[l][r];
            // cout<<cost[l][r]<<endl;
            i++;
            l=r;r=arr[i];
            // cout<<i<<" "<<l<<" "<<r<<endl;
        }
        r=arr[arr.size()-1];
        sum+=cost[r][1];
        // cout<<sum<<endl;
        if(sum==k) ans++;
    }while(next_permutation(all(arr)));
    cout<<ans;
}

int32_t main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cout.tie(NULL);
cin.tie(NULL);
    int t=1;
    // cin>>t;
    while (t--)
    {
        solve();
    }
    return 0;
}
#include <bits/stdc++.h>
using namespace std;

const int MOD = 1000000007;
const int INF = 1e9;
const long long INFLL = 1e18;
using ll = long long;

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

  vector<int> order;
  for(int i = 1; i < n; i++){
    order.push_back(i);
  }

  int ans = 0;
  do{
    int sum = 0;
    sum += t[0][order[0]];
    for(int i = 0; i < order.size(); i++){
      // cout << order[i];
      if(i == order.size()-1) sum += t[order[i]][0];
      else sum += t[order[i]][order[i+1]];
    }
    // cout << endl;
    if(sum == k) ans ++;
  }while(next_permutation(order.begin(), order.end()));

  cout << ans << endl;

  return 0;
}