#include <bits/stdc++.h>
using namespace std;
long long n, start, stop;
string a, b;
void check() {
  long long i, j, words = 0;
  for (i = start; i < stop; ++i) {
    if (a[i] != b[i + 1]) {
      break;
    }
  }
  if (i == stop) {
    ++words;
  }
  for (i = start; i < stop; ++i) {
    if (b[i] != a[i + 1]) {
      break;
    }
  }
  if (i == stop) {
    ++words;
  }
  cout << words;
}
int main() {
  long long i, j, k, n, m, t;
  cin >> n;
  cin >> a;
  cin >> b;
  long long c = 0;
  for (i = 0; i < n; ++i) {
    if (a[i] != b[i]) {
      ++c;
      if (c == 1) {
        start = i;
      }
      stop = i;
    }
  }
  if (c == 1)
    cout << "2";
  else
    check();
  return 0;
}
