#include <bits/stdc++.h>
using namespace std;
const int maxn = 111111;
char a[maxn], b[maxn];
int main() {
  int n;
  scanf("%d", &n);
  scanf("%s\n%s", a, b);
  int lp = 0, rp = n - 1;
  while (a[lp] == b[lp]) {
    lp++;
  }
  while (a[rp] == b[rp]) {
    rp--;
  }
  int ans = 0;
  bool ok = 1;
  for (int l = lp + 1; l <= rp; l++) {
    if (a[l] != b[l - 1]) {
      ok = 0;
      break;
    }
  }
  if (ok) {
    ans++;
  }
  ok = 1;
  for (int l = lp; l < rp; l++) {
    if (a[l] != b[l + 1]) {
      ok = 0;
      break;
    }
  }
  if (ok) {
    ans++;
  }
  cout << ans << endl;
  return 0;
}
