

  #include <bits/stdc++.h>
  #define endl "\n"
  #define int long long int
  #define vi vector<int>
  #define vll vector<ll>
  #define vvi vector < vi >
  #define pii pair<int,int>
  #define pll pair<long long, long long>
  #define mod 1000000007
  #define inf 1000000000000000001;
  #define all(c) c.begin(),c.end()
  #define mp(x,y) make_pair(x,y)
  #define clr(a,val) memset(a,val,sizeof(a))
  #define repp(i, a, b)  for(int i = a; i < b; i++)
  #define rep(i, a, b)  for(int i = a; i <= b; i++)
  #define pb push_back
  #define f first
  #define s second
  
  using namespace std;

  void solve(){
     int n, k;
     cin >> n >> k;
     int a[n+1][n+1];
     rep(i, 1, n){
         rep(j, 1, n){
             cin >> a[i][j];
         }
     }
     int p[n];
     repp(i, 0, n){
         p[i] = i+1;
     }
     int cnt = 0;
     do{
         int prev = p[0];
         int sum = 0;
        //  for(int i = 0; i <n; i++)
        //     cout << p[i] << " ";
        //  cout << endl;
         for(int i = 1; i < n; i++){
            sum += a[prev][p[i]];
            prev = p[i];
         }
         sum += a[p[n-1]][1]; 
         if(sum == k)  cnt++;
     }while(next_permutation(p+1, p+n));
     cout << cnt;
  }

  int32_t main()
  {
    int T = 1;  //cin >> T;
    for(int t=1;t<=T;t++)
    {
      solve();
      //cout<<"Case #"<<t<<": "<<ans<<endl;
    }

    return 0;
  }

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

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
#define int ll

#define pb push_back
#define F first
#define S second
#define _sz(x) ((int)x.size())

#define fastio ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)

const int N = 10;
int g[N][N];
int st[N];
int n,T;
int res;
void dfs(int u,int step,int c)
{
    if(step==n-1){
        if(c+g[u][1]==T) res++;
        return;
    }
    for(int i = 1; i <= n; i++){
        if(!st[i]){
            if(c+g[u][i] < T){
                st[i] = 1;
                dfs(i,step+1,c+g[u][i]);
                st[i] = 0;
            }
        }
    }
}
signed main()
{
    fastio;
    cin >> n >> T;
    memset(st,0,sizeof(st));
    for(int i = 1; i <=  n; i++)
        for(int j = 1; j <= n; j++) cin >> g[i][j];
    st[1] = 1;
    dfs(1,0,0);
    cout << res <<endl;
}
