#include <bits/stdc++.h>
using namespace std;
int n;
string s1, s2;
long long int dp[100005][2][2];
int solve(int in, int x1, int x2) {
  if (x1 > 1 || x2 > 1) return 0;
  if (in == n + 1) {
    if (x1 == 1 && x2 == 1)
      return 1;
    else
      return 0;
  }
  long long int &ret = dp[in][x1][x2];
  if (ret != -1) return ret;
  int c1 = in - x1, c2 = in - x2, i;
  ret = 0;
  for (i = 0; i < 26; i++) {
    if (c1 < n && c2 < n)
      ret += solve(in + 1, x1 + (s1[c1] - 'a' != i), x2 + (s2[c2] - 'a' != i));
    else if (c1 == n)
      ret += solve(in + 1, x1 + 1, x2 + (s2[c2] - 'a' != i));
    else if (c2 == n)
      ret += solve(in + 1, x1 + (s1[c1] - 'a' != i), x2 + 1);
    else
      ret += solve(in + 1, x1 + 1, x2 + 1);
  }
  return ret;
}
int main() {
  int i, j, k;
  cin >> n;
  cin >> s1 >> s2;
  for (i = 0; i < 100002; i++)
    for (k = 0; k < 2; k++) dp[i][k][0] = dp[i][k][1] = -1;
  cout << solve(0, 0, 0) << endl;
  ;
  return 0;
}
