#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

ll mod = 1e9+7;

int main(){
    int N;cin >> N;
    string s,t;cin >> s >> t;
    map<char, ll> mp;
    mp[s.front()]++;
    for(int i = 1;i < N;i++){
        if(i == N-1 && s[i] && t[i])break;
        mp[s[i]] %= mod;
        mp[t[i]] %= mod;
        mp[s[i]] += mp[t[i]];
        mp[s[i]] %= mod;
    }
    cout<<mp[t.back()] % mod<<endl;
}

