#include <bits/stdc++.h>
using namespace std;
char s1[100005], s2[100005], l;
int i, j, k, dp[100005][4][4], n, J, K;
void add(int &a, int b) { a += b; }
int main() {
  scanf("%d", &n);
  scanf("%s", s1);
  scanf("%s", s2);
  dp[0][1][1] = 1;
  for (i = 0; i <= n; i++) {
    for (j = 1; j <= 3; j++)
      for (k = 1; k <= 3; k++)
        if (dp[i][j][k]) {
          for (l = 'a'; l <= 'z'; l++) {
            J = j * 2 % 4;
            K = k * 2 % 4;
            if ((j & 1) && l == s1[i]) J |= 1;
            if ((k & 1) && l == s2[i]) K |= 1;
            if ((j & 2) && l == s1[i - 1]) J |= 2;
            if ((k & 2) && l == s2[i - 1]) K |= 2;
            dp[i + 1][J][K] += dp[i][j][k];
          }
        }
  }
  cout << dp[n + 1][2][2] + dp[n + 1][2][3] + dp[n + 1][3][3] + dp[n + 1][3][2];
  return 0;
}
