#include <bits/stdc++.h>

#define debug(x) cerr << #x << " = " << x << endl

using namespace std;
typedef long long LL;

const int MAXN = 55;
const int MOD = 1E9 + 7;
LL n, x, a[MAXN], g[MAXN], dp[MAXN][2];

template <class T>
void read(T& x) {
    x = 0;
    T f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') f = (ch == '-' ? -1 : 1), ch = getchar();
    while (ch >= '0' && ch <= '9') x = x * 10 + ch - 48, ch = getchar();
    x *= f;
}

template <class T, class... Args>
void read(T& x, Args&... args) {
    read(x), read(args...);
}

signed main() {
    read(n, x);
    for (int i = 1; i <= n; i++) read(a[i]);
    for (int i = n; i >= 1; i--) {
        if (!x) break;
        g[i] = x / a[i], x %= a[i];
    }
    for (int i = n - 1; i >= 1; i--) {
        LL lim = a[i + 1] / a[i];
        if (g[i] == 0) {
            dp[i][0] = dp[i + 1][0];
            dp[i][1] = dp[i + 1][1] + dp[i + 1][0] + 1;
        } else if (g[i] == lim - 1) {
            dp[i][0] = dp[i + 1][0] + dp[i + 1][1] + 1;
            dp[i][1] = dp[i + 1][1];
        } else {
            dp[i][1] = dp[i + 1][1] + dp[i + 1][0] + 1;
            dp[i][0] = dp[i + 1][0] + dp[i + 1][1] + 1;
        }
    }
    cout << dp[1][0] + 1;
    return 0;
}
/*
ID: febrian3
TASK: test
LANG: C++                 
*/

/*
#pragma GCC optimize("Ofast")
#pragma GCC target("avx", "avx2", "fma")
#pragma GCC optimization("unroll-loops")
*/

#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
const ld pi = 4*atan((ld)1);
const ll mod = 1e9 + 7;
const ll inf = 1e9;
const ll llinf = 1e18;
const ll nax = 0;
int h, w;

int main(){ 
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	//freopen("test.in", "r", stdin);
	//freopen("test.out", "w", stdout);
	cin >> h >> w;
	int mins=inf, kecil=inf;
	int arr[h+5][w+5];
	for(int i=0;i<h;++i){
		for(int j=0;j<w;++j){
			cin >> arr[i][j];
			kecil=min(kecil, arr[i][j]);
		}
	}
	for(int x=0;x<=min(100, kecil);++x){
		int cur=0;
		for(int i=0;i<h;++i){
			for(int j=0;j<w;++j){
				if(arr[i][j]<x){
					cur=inf;
					goto sini;
				}
				cur+=arr[i][j]-x;
			}
		}
		sini:;
		mins=min(mins, cur);
	}
	cout << mins << '\n';
}
