#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")    
using namespace std;
#define ll long long
#define INF 9999999999999999
#define rep(i,m,n) for(ll i = m;i < n;i++)
#define rrep(i,m,n) for(ll i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(50) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define tint tuple<int, int, int>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 1000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N, X, res = 0;
    cin >> N >> X;
    vector<vector<ll>> A(N);
    vector<map<ll, ll>> dp(N);
    dp[0][X] = 1;
    rep(i, 0, N) {
        ll a;
        cin >> a;
        A[0].emplace_back(a);
    }
    rep(i, 1, N) rep(j, 1, A[i - 1].size()) A[i].emplace_back(A[i - 1][j] / A[i - 1][1]);

    rep(i, 1, N) for(auto v : dp[i - 1]) {
        if(v.first == 1) continue;
        if(v.first % A[i - 1][1]) dp[i][v.first / A[i - 1][1] + 1] += v.second;
        dp[i][v.first / A[i - 1][1]] += v.second;
    }
    rep(i, 0, N) if(dp[i].count(1)) res += dp[i][1] * A[i].size();
    for(auto v : dp[N - 1]) if(v.first != 1) res += v.second;
    cout << res << endl;
}
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long int ull;
#define pii pair<ll,ll>
#define vi vector<ll>
#define vii vector<pii>
#define endl "\n"
#define pb push_back
#define sq(a) ((a)*(a))
#define sz(x) (ll)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(a) (a).rbegin(),(a).rend()
#define x first
#define y second
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugv(v) cerr<<#v<<" : "; for(auto x:v) cerr<<x<<' '; cerr<<endl;
#define output(x) cout<<(x ? "YES" : "NO")<<endl;
#define Output(x) cout<<(x ? "Yes" : "No")<<endl;
#define MOD (1000000007)
#define MOD2 (998244353)
#define PI acos(-1)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll exp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n)
    {
        if(n & 1)
            result=(result * x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return result;
}

const int N = 1001;

ll a[N],b[N];
ll dp[N][N];

ll rec(int n,int m)
{
	if(!n || !m)
		return (n^m);

	if(dp[n][m] != -1)
		return dp[n][m];

	return dp[n][m] = min({rec(n-1,m-1) + (a[n]!=b[m]), rec(n-1,m) + 1, rec(n,m-1) + 1});
}

int32_t main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    IOS

    int n,m;
    cin>>n>>m;

    for(int i=1;i<=n;i++)
    	cin>>a[i];

    for(int i=1;i<=m;i++)
    	cin>>b[i];

    for(int i=1;i<=n;i++)
      for(int j=1;j<=m;j++)
        dp[i][j]=-1;

    cout<<rec(n,m)<<endl;
    return 0;
}