#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    string s, t; cin >> s >> t;
    vector<ll> dp(30, 0);
    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[n - 1] - 'a'] << endl;
    return 0;
}
