#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int mm = 100005;
char s1[mm], s2[mm];
int check(char *sa, int a, char *sb, int b, int l) {
  for (int i = 0; i < l; i++)
    if (sa[a + i] != sb[b + i]) return 0;
  return 1;
}
int main() {
  int n;
  while (cin >> n) {
    int ans = 0;
    cin >> s1 >> s2;
    int l = 0, r = strlen(s1) - 1;
    while (s1[l] == s2[l] && l <= r) l++;
    while (s1[r] == s2[r] && r >= l) r--;
    ans = check(s1, l + 1, s2, l, r - l) + check(s1, l, s2, l + 1, r - l);
    cout << ans << endl;
  }
  return 0;
}
