#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  string a, b;
  cin >> n >> a >> b;
  long long l = 0;
  while (l < n && a[l] == b[l]) l++;
  long long r = n - 1;
  while (r >= 0 && a[r] == b[r]) r--;
  if (l == r) {
    cout << 2;
  } else {
    long long cnt = 0;
    string as = string(a.begin() + l + 1, a.begin() + r + 1);
    string bs = string(b.begin() + l, b.begin() + r);
    if (as == bs) cnt++;
    swap(a, b);
    as = string(a.begin() + l + 1, a.begin() + r + 1);
    bs = string(b.begin() + l, b.begin() + r);
    if (as == bs) cnt++;
    cout << cnt;
  }
  return 0;
}
