#include<iostream>
#include<vector>

using namespace std;
using ll = long long;

int main() {
	int n; ll x;
	cin >> n >> x;

	vector<int> A(n);
	for (auto& Ai : A) cin >> Ai;

	ll ans = (ll)2e18;
	for (int base = 1; base <= n; base++) {
		vector<vector<int>> T(base + 1, vector<int>(base, -(int)2e9));
		T[0][(base-(x%base))%base] = 0;
		for (auto ind : A) {
			for (int i = base - 1; i >= 0; i--) {
				for (int j = 0; j < base; j++) {
					if (T[i][j] + ind > T[i + 1][(j + ind) % base]) {
						T[i + 1][(j + ind) % base] = T[i][j] + ind;
					}
				}
			}
		}
		if (T[base][0] < 0) continue;
		ans = min(ans, (x - T[base][0]) / base);
	}
	cout << ans << '\n';

}
#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef long double ld;
#define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define FOR(i, n, m) for(ll i = (ll)n; i < (ll)(m); i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define PRINT(x) std::cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dx[8] = {0,1,0,-1, 1, -1, 1, -1}, dy[8] = {1,0,-1,0,1,1,-1,-1};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) os << v[i] << " ";  
    return os; 
}

template <typename T1, typename T2> 
ostream& operator<<(ostream& os, const map<T1, T2>& m) 
{ 
    for (auto p : m) os << "<" << p.first << ", " << p.second << "> "; 
    return os; 
}

int main()
{ 
  ll N, K;
  cin >> N >> K;
  vector<vector<ll>> mat(N, vector<ll>(N, 0));
  REP(i, N) {
    REP(j, N){
      cin >> mat[i][j];
    }
  }
  
  vector<ll> indices(N-1);
  iota(indices.begin(), indices.end(), 1);
  ll cnt = 0;
  do {
      ll sum = mat[0][indices[0]];
      REP(i, N-2) {
        sum += mat[indices[i]][indices[i+1]];
      }
      sum += mat[indices[N-2]][0];
      if (K == sum) cnt++;
  } while (std::next_permutation(indices.begin(), indices.end()));
  cout << cnt << endl;
  return 0;
} 
