#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPE(i,l,n) for(ll i=l;i<=ll(n);i++)
#define FORA(i,I) for(const auto& i:I)
#define ALL(v) v.begin(),v.end()
#define UQ(v) v.erase(unique(ALL(v)), v.end())
#define ACM(v) accumulate(ALL(v), 0)
#define P(str) cout << str << endl
#define VLL vector<ll>
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
constexpr int64_t INF = 1e18;

int main() {
    ll n, k;
    cin >> n >> k;
    vector<VLL> v(n, VLL(n));
    REP(i, n)REP(j, n){
        cin >> v[i][j];
    }
    ll cnt = 0;
    VLL a(n - 1);
    iota(ALL(a),1);
    do{
        ll p = 0;
        ll tmp = 0;
        REPE(i, 0, n - 2){
            tmp += v[p][a[i]];
            p = a[i];
        }
        tmp += v[p][0];
        if(tmp == k) ++cnt;
    }while(next_permutation(ALL(a)));
    P(cnt);
}
// Code written by Shubham Agarwal

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define V 8
using namespace std;

void tsp(ll graph[][V], vector<bool>& v, ll currPos, 
         ll n, ll count, ll cost, ll& ans, ll k, int &cnt) 
{ 
    if (count == n && graph[currPos][0]) { 
    	if(cost + graph[currPos][0] == k)
    		cnt++;
        ans = min(ans, cost + graph[currPos][0]); 

        return; 
    } 

    for (int i = 0; i < n; i++) { 
        if (!v[i] && graph[currPos][i]) { 
  
            v[i] = true; 
            
            tsp(graph, v, i, n, count + 1, 
                cost + graph[currPos][i], ans, k, cnt); 
  
            v[i] = false; 
        } 
    } 
}

int main(){
	fastio;
	ll n, k;
	cin >> n >> k;
	ll graph[V][V];
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			cin >> graph[i][j];
		}
	}
	vector<bool> v(n); 
    for (int i = 0; i < n; i++) 
        v[i] = false; 
   v[0] = true; 
    ll ans = INT_MAX; 
    int cnt = 0;
    tsp(graph, v, 0, n, 1, 0, ans, k, cnt); 
  
    cout << cnt; 
	return 0;
}