#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int N,K;
    cin >> N >> K;
    int T[N][N];
    for(int i=0;i<N;i++)for(int j=0;j<N;j++){
        cin >> T[i][j];
    }
    
    vector<int> p;
    for(int i=0;i<N;i++){
        p.push_back(i);
    }
    p.push_back(0);
    
    int ans = 0;
    do{
        int sum = 0;
        for(int i=0;i<N;i++){
            sum += T[p[i]][p[i+1]];
        }
        if(sum == K){
            ans++;
        }
    }while(next_permutation(p.begin()+1,p.end()-1));
    
    cout << ans;
}

#include<bits/stdc++.h>
#define For(a,b,c) for(int a=b;a<=c;++a)
#define Dor(a,b,c) for(int a=b;a>=c;--a)
using namespace std;
typedef long long LL;
int n,k;
int S(int t) {
	int l=max(1,t-n),r=min(n,t-1);
	return max(r-l+1,0);
}
int main() {
	cin>>n>>k;
	LL s=0;
	For(i,1,n+n) {
		s+=1LL*S(i)*S(i+k);
	}
	cout<<s;
	return 0;
}