#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s1, s2;
  cin >> s1 >> s2;
  int ans = 0;
  int start = 0;
  int end = n - 1;
  while (s1[start] == s2[start]) start++;
  while (s1[end] == s2[end]) end--;
  if (s1.substr(start, end - start) == s2.substr(start + 1, end - start)) ans++;
  if (s2.substr(start, end - start) == s1.substr(start + 1, end - start)) ans++;
  cout << ans << endl;
  return 0;
}
