#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = ll(1e9+7);
#define REP(i, n) for (int i = 0; i < n; i++)

int main() {
    ll n, dp[26]{};
    string s, t;
    cin >> n >> s >> t;
    dp[s[0]-'a'] = 1;
    for(int i=1;i<n-1;i++){
        dp[s[i]-'a'] += dp[t[i]-'a'];
        dp[s[i]-'a'] %= MOD;
    }
    cout << dp[t.back()-'a'] << endl;
    return 0;
}

