#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define ll 				long long
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define mii               map<ll,ll>
#define pqi             priority_queue<ll>			//max pq
#define pqd             priority_queue<ll,vi,greater<ll> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define MOD             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define pw(b,p)         pow(b,p) + 0.1
#define f(i,k,n)			for(ll i=k;i<n;i++)

ll power(ll a, ll b, ll mod) {ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) {if (b & 1)res = res * a % mod; a = a * a % mod;} return res;}
ll power(ll a, ll b) {ll res = 1; assert(b >= 0); for (; b; b >>= 1) {if (b & 1)res = res * a ; a = a * a;} return res;}
ll min( ll a,  ll b) { return (a < b) ? a : b;}
ll max(ll a, ll b) {return (a > b) ? a : b;}
ll gcd (ll a, ll b) {if (a == 0) return  b; return gcd(b % a, a);}



void bwayne()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

ll dfs(vi &vis, vector<vi> &a, ll index, ll n, ll k, ll curr) {
	vis[index] = 1;
	ll ans = 0;
	ll flag = 0;
	if (curr > k) {
		vis[index] = 0;

		return 0;
	}
	// cout << index << endl;
	f(i, 1, n) {
		if (vis[i] == 0) {
			flag = 1;
			break;
		}
	}
	if (flag == 0 && curr + a[index][0] == k) {
		vis[index] = 0;

		return 1;
	}
	for (int i = 1; i < n; i++) {
		if (a[index][i] >= 1 && vis[i] == 0) {
			ans += dfs(vis, a, i, n, k, curr + a[index][i]);
		}
	}
	vis[index] = 0;

	return ans;
}

ll finder(vector<vi>&a, ll n, ll k) {
	vi vis(n, 0);
	ll ans = 0;
	f(i, 1, n) {
		if (a[0][i] >= 1) {
			ans += dfs(vis, a, i, n, k, a[0][i]);
		}
	}
	return ans;
}
void solve() {
	ll n, k;
	cin >> n >> k;
	vector<vi> a(n, vi(n, 0));
	f(i, 0, n) {
		f(j, 0, n) {
			cin >> a[i][j];
		}
	}
	ll ans = finder(a, n, k);
	cout << ans;

}
int main()
{
	bwayne();// remember
	ll t = 1;
	//cin >> t;

	for (ll tt = 1; tt <= t; tt++)
	{
		// cout << "Case #" << tt << ": ";
		solve();
	}

	return 0;
}
#include <bits/stdc++.h>
#include <unordered_set>
#include <algorithm>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repll(i,n) for (ll i = 0; i < (ll)(n); i++)
#define fore(x,a) for(auto&(x) : (a))

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

#define ALL(a) (a).begin(), (a).end()

const ll INFL = 1e18;
const int INFI = 1e9;
const int MOD = 1e9 + 7;

long long N, K;
vector<vector<long long>> T;

int rec(long long dist = 0, int last = 0, int visited = (1<<0)) {
    if (visited == (1<<N)-1) {
        dist += T[last][0];
        if (dist == K) return 1;
        else return 0;
    }

    int res = 0;
    for (int v = 1; v < N; ++v) {
        if (visited & (1<<v)) continue;

        res += rec(dist+T[last][v], v, visited|(1<<v));
    }
    return res;
}

int main() {
    cin >> N >> K;
    T.assign(N, vector<long long>(N, 0));
    for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) cin >> T[i][j];
    cout << rec() << endl;
}

