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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

const int mod = 1000000007;
struct mint {
    long long x;
    mint(long long x = 0) : x((x % mod + mod) % mod) {}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return (*this) *= a.inv(); }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

int main() {
    int N;
    string S, T;
    cin >> N >> S >> T;

    vector<int> pattern(0);
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == T[i]) {
            pattern.push_back(0);
        } else {
            pattern.push_back(1);
            i++;
        }
    }

    mint ans;
    int prev_p;
    for (int i = 0; i < pattern.size(); i++) {
        if (i == 0) {
            if (pattern[0] == 0) {
                ans    = 3;
                prev_p = 0;
            } else {
                ans    = 6;
                prev_p = 1;
            }
        } else {
            int cur_p = pattern[i];

            if (prev_p == 0 and cur_p == 0) {
                ans *= 2;

            } else if (prev_p == 0 and cur_p == 1) {
                ans *= 2;
            } else if (prev_p == 1 and cur_p == 0) {
                ans *= 1;
            } else if (prev_p == 1 and cur_p == 1) {
                ans *= 3;
            } else {
                return 1;
            }
            prev_p = cur_p;
        }
    }

    dump(pattern);
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 3604