#include <bits/stdc++.h>
using namespace std;
int n, ans = 0, i, j, k;
string s1, s2;
int main() {
  cin >> n;
  cin >> s1;
  cin >> s2;
  for (i = 0; s1[i] == s2[i]; ++i)
    ;
  for (j = n - 1; s1[j] == s2[j]; --j)
    ;
  for (k = i; k < j && s1[k] == s2[k + 1]; ++k)
    ;
  if (j == k) ans++;
  for (k = i; k < j && s1[k + 1] == s2[k]; ++k)
    ;
  if (j == k) ans++;
  cout << ans;
  return 0;
}
