#include <bits/stdc++.h>
using namespace std;
const int base = 37;
const int MODULO = 666013;
const int NMAX = 100005;
int n, sol, pref[NMAX], suf[NMAX];
char a[NMAX], b[NMAX], c[NMAX], d[NMAX];
int main() {
  int i, pre, sf, len;
  bool ok;
  cin.sync_with_stdio(false);
  cin >> n;
  cin >> (a + 1) >> (b + 1);
  pre = sf = 0;
  pref[0] = 1;
  for (i = 1; i <= n; i++) {
    if (pref[i - 1] > 0 && a[i] == b[i]) pref[i] = i;
    pre = max(pre, pref[i]);
  }
  suf[n + 1] = 1;
  for (i = n; i >= 1; i--) {
    if (suf[i + 1] > 0 && a[i] == b[i]) suf[i] = n - i + 1;
    sf = max(sf, suf[i]);
  }
  for (i = pre + 1; i <= (n - sf); i++) {
    c[i - pre] = a[i];
    d[i - pre] = b[i];
  }
  len = n - sf - (pre + 1) + 1;
  ok = 1;
  for (i = 2; i <= len; i++)
    if (c[i] != d[i - 1]) ok = 0;
  sol += ok;
  ok = 1;
  for (i = 1; i < len; i++)
    if (c[i] != d[i + 1]) ok = 0;
  sol += ok;
  cout << sol << "\n";
  return 0;
}
