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

ll my_pow(ll x, ll n) {
    if (n == 0) return 1;
    if (n % 2 == 0) return my_pow(x * x, n / 2);
    return x * my_pow(x, n - 1);
}

int main() {
    int N;
    cin >> N;
    string s, t;
    cin >> s >> t;
    ll mod = my_pow(10, 9) + 7;
    ll d[26]{};
    d[s[0] - 'a'] = 1;
    for (int i = 1; i < N - 1; i++) {
        d[s[i] - 'a'] += d[t[i] - 'a'];
        d[s[i] - 'a'] %= mod;
    }
    cout << d[t[N - 1] - 'a'] << "\n";
    return 0;
}
