#include<cstdio>

bool vis[15];
int a[15][15], ans, n, k;

void dfs(int now, int tot, int cs) {
	vis[now] = 1;
//	printf("%d %d %d\n", now, tot, cs);
	if(cs == n + 1) {
		if(tot == k) {
			ans ++;
		} return;
	}
	if(cs == n) dfs(1, tot + a[now][1], cs + 1); 
	else {
		for(int i = 1; i <= n; i ++) {
			if(i == now) continue;
			if(vis[i]) continue;
			vis[i] = 1;
			dfs(i, tot + a[now][i], cs + 1);
			vis[i] = 0;
		} vis[now] = 0;
	}
}	 

int main() {
	scanf("%d %d", &n, &k);
	for(int i = 1; i <= n; i ++) {
		for(int j = 1; j <= n; j ++) {
			scanf("%d", &a[i][j]);
		}
	} dfs(1, 0, 1);
	printf("%d", ans);
} 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define FIO                     ios::sync_with_stdio(false); cin.tie(nullptr)
#define TC(t)                   int t; cin >> t; for(int i = 1; i <= t; i++)
#define deb(x)                  cerr << #x << " = " << x << endl
#define deb2(x, y)              cerr << #x << " = " << x << ", " << #y << " = " << y << endl
#define f0(i, a, n)             for(i = a; i < n; i++)
#define f1(i, a, n)             for(i = a; i <= n; i++)
#define ini(x, y)               memset(x, y, sizeof(x))
#define all(x)                  x.begin(), x.end()
#define sz(x)                   x.size()
#define ll                      long long int
#define pb                      push_back
#define ppb                     pop_back
#define mp                      make_pair
#define ff                      first
#define ss                      second
#define M                       1000000007
#define endl                    '\n'
#define bits(x)                 __builtin_popcountll(x)
#define zrbits(x)               __builtin_ctzll(x)
#define vi                      vector<int>
#define pii                     pair<int,int>
#define vpii                    vector<pii>
#define ordered_set             tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define multi_ordered_set       tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>

const int N = 1e5 + 1;
const int MX = 1e9;
const ll INF = 1e18;

using namespace std;
using namespace __gnu_pbds;

inline ll uceil(ll a,ll b) {return (a % b ? a / b + 1 : a / b);}
inline ll mod(ll x) {return ( (x % M + M) % M );}

template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {for(auto& x : v) os << x << " "; return os << '\n';}
template<typename... T> void in(T&... args) {((cin >> args), ...);}
template<typename... T> void out(T&&... args) {((cout << args << endl), ...);}
template<typename... T> void out2(T&&... args) {((cout << args << " "), ...);}

void solve() {
        ll n, k, i, j;
        cin >> n >> k;
        
        vector<vector<ll>> a(n, vector<ll>(n));
        f0(i, 0, n) {
                f0(j, 0, n) {
                        cin >> a[i][j];
                }
        }

        vector<ll> v(n);
        f0(i, 1, n) {
                v[i] = i;
        }

        ll ans = 0;
        ll sum = 0;
        sum += a[0][v[0]];
        f0(i, 0, n-1) {
                sum += a[v[i]][v[i+1]];
        }
        sum += a[v[i]][0];
        if(sum == k) ans++;
        while(next_permutation(all(v))) {
                sum = 0;
                sum += a[0][v[0]];
                f0(i, 0, n-1) {
                        sum += a[v[i]][v[i+1]];
                }
                sum += a[v[i]][0];
                if(sum == k) ans++;
        }
        out(ans/2);
}

int main () {
        FIO;
        // TC(t)
        solve();
        return 0;
}