#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string a, b;
  cin >> a >> b;
  int from, to;
  for (from = 0; a[from] == b[from]; from++)
    ;
  for (to = n - 1; a[to] == b[to]; to--)
    ;
  bool matchedL = true, matchedR = true;
  for (int i = from; i < to; i++) {
    if (a[i] != b[i + 1]) matchedL = false;
    if (b[i] != a[i + 1]) matchedR = false;
  }
  cout << (matchedL + matchedR) << endl;
  return 0;
}
