#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5;
const long long M = 20;
const long long SQ = 320;
const long long INF = 1e16;
const long long MOD = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  int l = 0, r = n - 1;
  while (s[l] == t[l]) l++;
  while (s[r] == t[r]) r--;
  int f = 1, f1 = 1;
  for (int i = l; i < r; i++)
    if (s[i] != t[i + 1]) f = 0;
  for (int i = l + 1; i <= r; i++)
    if (s[i] != t[i - 1]) f1 = 0;
  cout << f + f1 << '\n';
  return 0;
}
