
#include <bits/stdc++.h>

using namespace std;

template<typename T> vector<T> vin(int n) {
	vector<T> v(n);
	for (int i = 0; i < n; ++i) cin >> v[i];
	return v;
}

vector<int> vi(int n) {
	vector<int> v(n);
	for (int i = 0; i < n; ++i) v[i] = i;
	return v;
}

void in() {
}

template<typename Head, typename... Tail>
void in(Head& h, Tail&... tails) {
	cin >> h;
	in(forward<Tail&>(tails)...);
}

void init_cin(const std::string& s) {
	cin.rdbuf((new istringstream(s))->rdbuf());
}

void out() {
	cout << endl;
}

template<typename T, typename... Args>
void out(T&& head, Args&&... args) {
	cout << head << " ";
	out(forward<Args>(args)...);
}

template<template <typename T, typename A = allocator<T>> class Cont, typename T>
ostream& operator<<(ostream& os, const Cont<T>& c) {
	for (auto it = c.begin(); it != c.end(); ++it) {
		if (it != c.begin()) os << " ";
		os << *it;
	}
	return os;
}


int main() {
	auto f = [](int n, int k, const vector<vector<int>>& tt) {
		vector<int> cities = vi(n);

		int ans = 0;
		do {
			int time = 0;
			for (size_t i = 0; i < cities.size(); ++i) {
				time += tt[cities[i]][cities[(i+1)%n]];
			}
			if (time == k) ans++;
//			out(cities, "/", time, ans);
		} while (next_permutation(cities.begin()+1, cities.end()));

		out(ans);

	};

	int N, K;
	cin >> N >> K;
	vector<vector<int>> tt(N, vector<int>(N));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			cin >> tt[i][j];
		}
	}

	f(N, K, tt);

//	f(4, 330,
//			{
//				{0,     1,  10, 100},
//				{1,     0,  20, 200},
//				{10,   20,   0, 300},
//				{100, 200, 300,   0}
//			});

}



#include <bits/stdc++.h>

using namespace std;

#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);

typedef long long ll;
typedef pair<int, int> PII;

const int N = 10;
const int M = 110;

ll h[N], ne[M], e[M], w[M], idx;
ll ans;
int n;
ll k;
bool vis[N];
bool vis1;
int cnt = 1;
void add(int a, int b, int c)
{
    e[idx] = b;
    ne[idx] = h[a];
    w[idx] = c; 
    h[a] = idx++;
}

void dfs(int x, ll dis)
{
    if(cnt == n && x == 1)
        if(dis == k)
        {
            ans++;
            return;
        }
    
    vis[x] = true;
    cnt++;
    for(int i = h[x]; ~i; i = ne[i])
    {
        int j = e[i];
        if(vis[j])
            continue;
        
        ll tmp = dis + w[i];
        if(tmp > k)
            continue;
        
        dfs(j, tmp);
    }

    vis[x] = false;
    cnt--;
}

int main()
{

    IOS;
    memset(h, -1, sizeof h);
    cin >> n >> k;
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= n; j++)
        {
            int tmp;
            cin >> tmp;
            if(j < i)
                continue;

            add(i, j, tmp);
            add(j, i, tmp);
        }

    for(int i = h[1]; ~i; i = ne[i])
    {
        int t = e[i];
        dfs(t, w[i]);
    }

    cout << ans << endl;
}