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

#define int long long
#define rep(i, l, r) for (int i = l; i <= r; ++i)
#define dep(i, r, l) for (int i = r; i >= l; --i)

void read (int &x) {
	x = 0; char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	while (c >= '0' && c <= '9')
		x = x * 10 + c - 48, c = getchar();
}

const int N = 2e6 + 10, mod = 1e9 + 7;

int n, m, k, fac[N], inv[N];

int C (int n, int m) {
	if (n < m) return 0;
	if (m == 0) return 1;
	return fac[n] * inv[m] % mod * inv[n - m] % mod;
}

int Pow (int a, int k) {
	if (k == 1) return a;
	int S = Pow (a, k >> 1);
	if (k & 1) return S * S % mod * a % mod;
	else return S * S % mod;
}

signed main () {

	fac[0] = 1; rep(i, 1, N - 1) fac[i] = fac[i - 1] * i % mod;
	inv[N - 1] = Pow(fac[N - 1], mod - 2);
	dep(i, N - 2, 0) inv[i] = inv[i + 1] * (i + 1) % mod;
	
	read(n), read(m), read(k);
	if (m == 0 && k < n || m + k < n) puts("0");
	else printf("%lld", (C(n + m, n) - C(n + m, m + k + 1) + mod) % mod);

	return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

void solve(){
	int n,m;cin>>n>>m;
	vector<int>A(n);
	vector<int>B(m);
	for(int i=0;i<n;i++)cin>>A[i];
	for(int i=0;i<m;i++)cin>>B[i];
	int dp[n+1][m+1]={0};
	for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++){
			if (i==0&&j==0){
				dp[i][j]=0;
				continue;
			}
			dp[i][j]=1e18;
			if (i>0)dp[i][j]=min(dp[i][j],dp[i-1][j]+1);
			if (j>0)dp[i][j]=min(dp[i][j],dp[i][j-1]+1);
			if (i>0&&j>0)dp[i][j]=min(dp[i][j],dp[i-1][j-1]+(A[i-1]!=B[j-1]?1:0));
		}
	}
	cout<<dp[n][m]<<endl;
}
int32_t main(){
	IOS;
	int t=1;
	//cin>>t;
	while (t--)solve();
return 0;
}
