#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  int ii = 0, jj = n - 1;
  while (s[ii] == t[ii]) ii++;
  while (s[jj] == t[jj]) jj--;
  bool ok1 = true, ok2 = true;
  for (int i = ii; i < jj; i++) {
    ok1 &= (s[i] == t[i + 1]);
    ok2 &= (t[i] == s[i + 1]);
  }
  cout << ok1 + ok2 << endl;
  return 0;
}
