#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
constexpr int INF = 1001001000;

int main() {
    int n, k;
    cin >> n >> k;
    mat t(n, vec(n));
    rep(i, n) rep(j, n) cin >> t[i][j];

    int res = 0;

    vec a(n);
    rep(i, n) a[i] = i;
    a.push_back(0);

    do {
        int sum = 0;

        rep(i, n) {
            sum += t[a[i+1]][a[i]];
        }

        if (sum == k) res++;
    } while (next_permutation(a.begin() + 1, a.end() - 1));

    cout << res << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define mp make_pair
typedef long long int ll;
typedef pair<ll,ll> pll;
 
#define MOD 1000000007
bool visited[10];
ll cities[10][10];
ll n,k,ret = 0;

void go(int c,ll total,int visCount)
{
    if(visCount >= n-1)
    {
        if(total+cities[c][0] == k)
            ret++;
        return;
    }
    visited[c] = true;
    for(int i = 0;i < n;i++)
    {
        if(!visited[i])
        {
            if(total+cities[c][i] < k)
                go(i,total+cities[c][i],visCount+1);
        }
    }
    visited[c] = false;
}

void solve(){
    cin >> n >> k;
    for(int i = 0;i < n;i++)
        for(int j = 0;j < n;j++)
        {
            cin >> cities[i][j];
        }

    go(0,0,0);

    cout << ret;
}
int main(){
#ifdef DEBUG
    freopen("i.txt","r",stdin);
    freopen("o.txt","w",stdout);
#endif
    cin.tie(0);
    ios::sync_with_stdio(0);

	int q;
	//cin >> q;
    q = 1;
	while(q--){
		solve();
	}
	return 0;
}