#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const double eps = 1e-6;
const int mod = 1000000007;
inline string getstr(string &s, int l, int r) {
  string ret = "";
  for (int i = l; i <= r; i++) ret.push_back(s[i]);
  return ret;
}
int modpow(int x, int y, int md = mod) {
  if (y == 0) return 1;
  int ret = modpow(x, y >> 1, md);
  ret = (long long)ret * ret % md;
  if (y & 1) ret = (long long)ret * x % md;
  return ret;
}
string s, t;
int n;
int main() {
  cin >> n >> s >> t;
  int l, r;
  for (l = 0;; l++) {
    if (s[l] != t[l]) {
      break;
    }
  }
  for (r = n - 1;; r--) {
    if (s[r] != t[r]) {
      break;
    }
  }
  int lft = 1, rgt = 1;
  for (int i = l; i < r; i++) {
    if (s[i] != t[i + 1]) lft = 0;
    if (s[i + 1] != t[i]) rgt = 0;
  }
  cout << lft + rgt << endl;
  return 0;
}
