#include <bits/stdc++.h>
using namespace std;
const int maxn = 100100;
const int INF = 1e9 + 9;
int n;
int solve(char *s, char *t) {
  int pref = 0, suf = 0;
  while (pref < n && s[pref] == t[pref]) ++pref;
  while (suf < n && s[n - 1 - suf] == t[n - 1 - suf]) ++suf;
  for (int i = int(pref); i <= int(n - 1 - suf - 1); ++i)
    if (s[i + 1] != t[i]) return 0;
  return 1;
}
char s[maxn], t[maxn];
int main() {
  scanf("%d\n", &n);
  scanf("%s\n%s", s, t);
  printf("%d\n", solve(s, t) + solve(t, s));
  return 0;
}
