#include <bits/stdc++.h>
using namespace std;
long long dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
struct edge {
  long long to, cost;
};
long long N, a[26];
string s, t;
bool al(char c) { return 'A' <= c && c <= 'Z'; }
long long n = 26;
long long par[26], ran[26], siz[26];
void init(long long n) {
  for (long long i = 0; i < n; i++) {
    par[i] = i;
    siz[i] = 1;
    ran[i] = 0;
  }
}
long long find(long long x) {
  if (par[x] == x) return x;
  return par[x] = find(par[x]);
}
void unite(long long x, long long y) {
  x = find(x);
  y = find(y);
  if (x == y) return;
  if (ran[x] < ran[y]) {
    par[x] = y;
    siz[y] += siz[x];
  } else {
    par[y] = x;
    siz[x] += siz[y];
    if (ran[x] == ran[y]) ran[x]++;
  }
}
bool same(long long x, long long y) { return find(x) == find(y); }
long long Size(long long f) { return siz[find(f)]; }
long long ans = 1, start = -1;
bool used[26];
signed main() {
  cin >> N >> s >> t;
  fill(a, a + n, -1);
  init(n);
  for (long long i = 0; i < s.size(); i++) {
    char S = s[i], T = t[i];
    if (!al(S) && !al(T)) continue;
    if (!al(S) && al(T)) a[T - 'A'] = (long long)S - '0';
    if (al(S) && !al(T)) a[S - 'A'] = (long long)T - '0';
    if (al(S) && al(T)) unite((long long)S - 'A', (long long)T - 'A');
  }
  if (al(s[0]) && al(t[0])) start = find((long long)s[0] - 'A');
  for (long long i = 0; i < s.size(); i++) {
    if (!al(s[i]) || !al(t[i])) continue;
    long long S = (long long)s[i] - 'A';
    if (find(S) != S) continue;
    S = find(S);
    if (used[S]) continue;
    if (start == S)
      ans *= 9;
    else
      ans *= 10;
    used[S] = true;
  }
  cout << ans << endl;
  return 0;
}
