#include <iostream>
#include <string>
#include <vector>
#include <array>

using namespace std;
typedef long long ll;

struct mint{
    static const long long MOD = 1000000007;

    long long v;

    mint() : v(0) {}
    mint(long long x){
        x = x % MOD;
        if(x < 0){ x += MOD; }
        v = x;
    }
    mint& operator+=(mint a){
        v += a.v;
        if(v >= MOD){ v -= MOD; }
        return *this;
    }
    mint& operator*=(mint a){
        v *= a.v;
        v %= MOD;
        return *this;
    }
    mint& operator-=(mint a){
        v -= a.v;
        if(v < 0){ v += MOD; }
        return *this;
    }
    mint& operator/=(mint a){
        return (*this) *= a.inv();
    }

    mint operator*(mint a) const{
        return mint(v) *= a;
    }

    mint operator+(mint a) const {
        return mint(v) += a;
    }

    mint operator-(mint a) const {
        return mint(v) -= a;
    }

    mint operator/(mint a) const {
        return mint(v) /= a;
    }

    mint pow(long long k) const {
        mint res(1),tmp(v);
        while(k){
            if(k&1) res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    mint inv(){return pow(MOD - 2); }

    static mint comb(long long n, int k){
        mint res(1);
        for(int i = 0; i < k; ++i){
            res *= mint(n - i);
            res /= mint(i + 1);
        }
        return res;
    }

    static mint factorial(long long n){
        mint res(1);
        for(int i = n; i > 1; --i){
            res *= mint(i);
        }
        return res;
    }

    bool operator<(const mint &a) const {
        return v < a.v;
    };
};

mint operator*(long long l, mint r){ return r * l; }

int main(){
    ll n;
    cin >> n;
    string s1, s2;
    cin >> s1 >> s2;

    vector<array<array<mint, 3>, 3>> dp(n);

    for(int i = 0; i < n;){
        if(s1.at(i) == s2.at(i)){
            for(int c = 0; c < 3; ++c){
                if(i == 0){
                    dp[i][c][c] = 1;
                }else{
                    for(int c1 = 0; c1 < 3; ++c1){
                        for(int c2 = 0; c2 < 3; ++c2){
                            if(c != c1 && c != c2){
                                dp[i][c][c] += dp[i - 1][c1][c2];
                            }
                        }
                    }
                }
            }
            i++;
        }else{
            for(int c1 = 0; c1 < 3; ++c1){
                for(int c2 = 0; c2 < 3; ++c2){
                    if(c1 == c2){ continue; }
                    if(i == 0){
                        dp[i + 1][c1][c2] = 1;
                    }else{
                        for(int c3 = 0; c3 < 3; ++c3){
                            for(int c4 = 0; c4 < 3; ++c4){
                                if(c1 != c3 && c2 != c4){
                                    dp[i + 1][c1][c2] += dp[i - 1][c3][c4];
                                }
                            }
                        }
                    }
                }
            }
            i += 2;
        }
    }

    mint ans = 0;
    for(int c1 = 0; c1 < 3; ++c1){
        for(int c2 = 0; c2 < 3; ++c2){
            ans += dp[n - 1][c1][c2];
        }
    }
    cout << ans.v << endl;
    return 0;
}


Measured memory_bytes: 888