#include <bits/stdc++.h>
char s[2000010], t[2000010];
int n;
int main() {
  scanf("%d", &n);
  scanf("%s%s", s, t);
  int a1 = 0, a2 = n - 1;
  while (a1 < n && s[a1] == t[a1]) a1++;
  while (a2 >= 0 && s[a2] == t[a2]) a2--;
  int ans = 0;
  bool ok = true;
  for (int i = a1; i < a2; i++)
    if (s[i] != t[i + 1]) {
      ok = false;
      break;
    }
  ans += ok;
  ok = true;
  for (int i = a1 + 1; i <= a2; i++)
    if (s[i] != t[i - 1]) {
      ok = false;
      break;
    }
  ans += ok;
  printf("%d\n", ans);
  return 0;
}
