#include<bits/stdc++.h>

#define rep(i,f,n) for (long long (i) =(f);(i)<(n);(i)++)
#define MOD 1000000007 
typedef  long long ll;

using namespace std;

int main(){
    int n;
    string s,t;
    cin>>n;
    cin>>s;
    cin>>t;
    vector<ll>csum(27,0),dp(n,0);
    csum[s[0]-'a']=1;
    dp[0]=1;
    rep(i,1,n){

        dp[i]=(dp[i]+csum[t[i]-'a'])%MOD;
        csum[s[i]-'a']+=dp[i];
       // cout<<dp[i]<<" "<<csum[t[i]-'a']<<s[i]<<t[i]<<endl;
        
    }
cout<<dp[n-1]<<endl;
return 0;
}
