#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

const LL mod = 1000000007;
LL N;
std::string s, t;
std::vector<std::vector<LL>>memo;

LL dp(LL i, char j)
{
	if (i == N - 1)
	{
		if (t[i] == j) return 1;
		else return 0;
	}
	if (memo[i][j - 'a'] != -1) return memo[i][j - 'a'];

	LL res;
	if (t[i] != j) res = dp(i + 1, j);
	else res = dp(i + 1, s[i]) + dp(i + 1, j);
	return memo[i][j - 'a'] = res % mod;
}

int main()
{
	in >> N >> s >> t;

	memo.resize(N, std::vector<LL>(30, -1));
	out << dp(1, s[0]) << std::endl;
}

