#include <bits/stdc++.h>
const int MAXN = 1e5 + 5;
char str1[MAXN], str2[MAXN];
int solve(char s1[], char s2[], int p1, int p2) {
  int ans = 1;
  for (int i = p1 + 1; i <= p2; ++i) {
    if (s1[i] != s2[i - 1]) {
      ans = 0;
      break;
    }
  }
  return ans;
}
int main() {
  int n;
  while (~scanf("%d", &n)) {
    int ans = 0, p1, p2;
    scanf("%s%s", str1, str2);
    for (int i = 0; i < n; ++i) {
      if (str1[i] != str2[i]) {
        p1 = i;
        break;
      }
    }
    for (int i = n - 1; i >= 0; --i) {
      if (str1[i] != str2[i]) {
        p2 = i;
        break;
      }
    }
    ans += solve(str1, str2, p1, p2);
    ans += solve(str2, str1, p1, p2);
    printf("%d\n", ans);
  }
  return 0;
}
