#include <iostream>
#include <string>

using namespace std;

int main() {
	static const int INF = 1e9 + 7;
	int n;
	cin >> n;
	string str1, str2;
	cin >> str1;
	cin >> str2;
	int dp[26] = {};
	dp[str1[0] - 'a']++;
	for (int i = 1; i < n - 1; i++) {
		dp[str1[i] - 'a'] += dp[str2[i] - 'a'];
		dp[str1[i] - 'a'] %= INF;
	}
	cout << dp[str2[n - 1] - 'a'] << "\n";
}
