#include <bits/stdc++.h>
using namespace std;
char s[100500], t[100500];
int main() {
  int n;
  scanf("%d\n", &n);
  gets(s);
  gets(t);
  int l = 0;
  while (s[l] == t[l]) l++;
  int r = n - 1;
  while (s[r] == t[r]) r--;
  int ans = 0;
  ans += memcmp(s + l, t + l + 1, r - l) == 0;
  ans += memcmp(s + l + 1, t + l, r - l) == 0;
  printf("%d\n", ans);
}
