#include <bits/stdc++.h>
using namespace std;

#define ll          long long
#define ld          long double
#define pb          push_back
#define nl          '\n'
#define X           first
#define Y           second
#define nimble      ios::sync_with_stdio(0);cin.tie(0);
#define all(v)      (v).begin(),(v).end()
#define _sz(x)      (int)x.size()
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define repr(i,b,a) for(int i=b;i>=a;i--)
#define preci(x)    fixed<<setprecision(x)
#define tc          int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');
    cerr.write(names,comma-names)<<" : "<<arg1<<" | ";
    __f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const ld pi=2*acos(0.0);

int main(){
    nimble;
    int n,k;
    cin>>n>>k;
    vector<vector<ll>> ct(n,vector<ll>(n));
    rep(i,0,n)
        rep(j,0,n)
            cin>>ct[i][j];
    vector<int> p;
    rep(i,1,n)
        p.pb(i);
    int cnt=0;
    do{
        ll cst=0;
        int in=0;
        rep(i,0,_sz(p)){
            cst+=ct[in][p[i]];
            in=p[i];
            if(i==_sz(p)-1)
                cst+=ct[0][p[i]];
        }
        if(cst==k)
            cnt++;
    }while(next_permutation(all(p)));
    cout<<cnt;
    return 0;
}
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
#include <random>
#include <cassert>
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define REPE(i, n) for (int (i)=0; (i) <= (n); (i)++)
#define CONTAINS_MAP(m, a) ((m).find((a)) != m.end())
#define CONTAINS_SET(m, a) ((m).find((a)) != m.end())
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; exit(0); }
void Yes() { cout << "Yes" << endl; exit(0); }
void No() { cout << "No" << endl; exit(0); }


signed main()
{
	char s, t;
	cin >> s;
	cin >> t;
	if (s == 'Y')
	{
		cout << (char)(t + ('A' - 'a')) << endl;
	}
	else
	{
		cout << t << endl;
	}

}

