#include <bits/stdc++.h>
using namespace std;
char s1[1000010], s2[1000010], s[26][1000010], t[26][1000010];
bool ok1[26], ok2[26];
int n;
int main() {
  while (scanf("%d", &n) == 1) {
    scanf("%s%s", s1, s2);
    int ans = 0;
    int p = 0;
    while (p < n && s1[p] == s2[p]) p++;
    memset(ok1, 0, sizeof(ok1));
    memset(ok2, 0, sizeof(ok2));
    for (int i = 0; i <= 25; i++) {
      memcpy(s[i], s1, sizeof(char) * p);
      s[i][p] = (char)(i + 'a');
      memcpy(s[i] + p + 1, s1 + p, sizeof(char) * (n - p));
      int skip = 0;
      for (int j = p, j1 = p; j <= n && j1 < n; j++, j1++)
        if (s[i][j] != s2[j1]) {
          skip++;
          j1--;
          if (skip >= 2) break;
        }
      if (skip <= 1) {
        ok1[i] = 1;
        ans++;
      }
    }
    for (int i = 0; i <= 25; i++) {
      memcpy(t[i], s2, sizeof(char) * p);
      t[i][p] = (char)(i + 'a');
      memcpy(t[i] + p + 1, s2 + p, sizeof(char) * (n - p));
      int skip = 0;
      for (int j = p, j1 = p; j <= n && j1 < n; j++, j1++)
        if (t[i][j] != s1[j1]) {
          skip++;
          j1--;
          if (skip >= 2) break;
        }
      if (skip <= 1) {
        ok2[i] = 1;
        ans++;
      }
    }
    for (int i = 0; i <= 25; i++)
      for (int j = 0; j <= 25; j++)
        if (ok1[i] && ok2[i] && memcmp(s[i], t[i], sizeof(char) * (n + 1)) == 0)
          ans--;
    printf("%d\n", ans);
  }
  return 0;
}
