#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>

using namespace std;

const int N = 1e6 + 10, M = 2e6 + 10, inf = 0x3f3f3f3f;

const long long Linf = 0x3f3f3f3f3f3f3f3f;

inline int read() {
	bool sym = 0; int res = 0; char ch = getchar();
	while (!isdigit(ch)) sym |= (ch == '-'), ch = getchar();
	while (isdigit(ch)) res = (res << 3) + (res << 1) + (ch ^ 48), ch = getchar();
	return sym ? -res : res;
}

int n, k, dis[10][10], ans, vis[10], cnt;

void dfs(int x, int u, int DIS) {
	if (x == n) {ans += (DIS + dis[u][1] == k);}
	vis[u] = 1;
	for (int v = 1; v <= n; v++) {
		if (!vis[v]) dfs(x + 1, v, DIS + dis[u][v]);
	}
	vis[u] = 0;
}

int main() {
	n = read(); k = read();
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			dis[i][j] = read();
		}
	}
	dfs(1, 1, 0); printf("%d", ans);
	return 0;
}
#include<bits/stdc++.h>
#include <iostream> 
#include <string> 
#define lli long long int
#define deb1(x) cout<<#x<<" :: "<<x<<"\n";
#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define deb2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define deb3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define deb(v) for(lli i=0;i<v.size();i++) {cout<<v[i]; (i==v.size()-1) ? cout<<"\n":cout<<" "; }
#define all(a) a.begin(),a.end()
#define ll long long
using namespace std;
#define f first
#define sd second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define sz(x) (ll)x.size()
#define vl vector<lli>
#define pii pair<lli,lli>
lli mod=1e9+7;
lli inf=LONG_MAX;
using namespace std;
lli t,n,x,y,z,k;
struct trip{
    lli f,sd,th;
};
const lli N = 3*100001;
int g[9][9];
int ok[10];
int dis[10];
lli sol(int i,int j){
    ok[i]=1;
    lli a=0;
    int fl=0;
    for(int l=1;l<n;++l){
        if(!ok[l]){
            fl=1;
            a+=sol(l,j+g[i][l]);
        }
    }
    ok[i]=0;
    if(fl==0){
        if(j+g[i][0]==k)return 1;
        else return 0;
    }
    return a;
}
int main(){
    fast
    t=1;
//    cin>>t;
    while(t--){
        cin>>n>>k;
        for(int i=0;i<n;++i){
            ok[i]=0;
            dis[i]=0;
            for(int j=0;j<n;++j)cin>>g[i][j];
        }
        cout<<sol(0,0)<<endl;
        
    }     
}