#include <bits/stdc++.h>
using namespace std;
int L;
string s, t;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> L >> s >> t;
  int le = 0, re = L - 1, i, j;
  while (s[le] == t[le]) le++;
  while (s[re] == t[re]) re--;
  for (i = le + 1; i <= re; i++)
    if (s[i] != t[i - 1]) break;
  for (j = le; j < re; j++)
    if (s[j] != t[j + 1]) break;
  cout << (i == re + 1) + (j == re);
  return 0;
}
