#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
using ui = unsigned int;
using ull = unsigned long long;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vui = vector<ui>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
template <typename T>
using vv = vector<vector<T>>;
template <typename T>
using vvv = vector<vector<vector<T>>>;

int main()
{
	int N, M;
	cin >> N >> M;
	vi A(N);
	vi B(M);
	for (auto& i : A)
	{
		cin >> i;
	}
	for (auto& i : B)
	{
		cin >> i;
	}

	vvi dp(N + 1, vi(M + 1, INT_MAX));
	dp[0][0] = 0;
	for (auto i = 0; i <= N; ++i)
	{
		for (auto j = 0; j <= M; ++j)
		{
			if (dp[i][j] == INT_MAX)
			{
				continue;
			}

			if (i < N)
			{
				dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + 1);
			}
			if (j < M)
			{
				dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + 1);
				if (i < N)
				{
					auto temp = dp[i][j];
					if (A[i] != B[j])
					{
						++temp;
					}
					dp[i + 1][j + 1] = min(dp[i + 1][j + 1], temp);
				}
			}
		}
	}
	cout << dp[N][M] << endl;

	return 0;
}
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <iomanip>
#include <functional>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <map>
#include <set>
#include <unordered_set>
using namespace std;
typedef long long ll;
#define rep(i,n) for (ll i = 0; i < (ll)(n); i++)
#define REP(i,n) for (ll i = 1; i <= (ll)(n); i++)
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define all(v) v.begin(), v.end()
#define pb push_back
#define vt vector
#define fcout cout<<fixed<<setprecision(15)
#define PI 3.1415926535897932384626433832795028841971693993751058209749445923078160628620899
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ll INF = 1000000000000000000;
const ll NIL = -1;
const ll dx[4] = { 0,1,0,-1 };
const ll dy[4] = { 1,0,-1,0 };

ll N, X, A[110];

int main() {
	cin >> N >> X;
	rep(i, N) cin >> A[i];
	ll ANS = INF;
	for (ll c = 1; c <= N; c++) {
		ll dp[105][105][105];
		ll q = X % c;
		FOR(i, 0, N)FOR(j, 0, N)FOR(k, 0, c - 1) dp[i][j][k] = -1000000000000000000;
        FOR(i, 0, N) dp[i][0][0]=0;
		FOR(i, 1, N)FOR(j, 1, i)FOR(k, 0, c - 1) {
			ll p = k + c - (A[i - 1] % c);
			p %= c;
			if (i == j) {
				dp[i][j][k] = A[i - 1] + dp[i - 1][j - 1][p];
			}
			else {
				dp[i][j][k] = max(dp[i - 1][j][k], A[i - 1] + dp[i - 1][j - 1][p]);
			}
		}
		ll k = dp[N][c][q];
		if (k > 0) {
			ll tmp = (X - k) / c;
			ANS = min(ANS, tmp);
        }
	}
	cout << ANS << endl;
	return 0;
}
