#include <bits/stdc++.h>
using namespace std;
string s1, s2, s3, s4;
int is_ok(string& t, string& m) {
  int sz = t.size();
  int s = 0, e = sz - 1;
  while (s < sz - 1 && t[s] == m[s]) {
    s++;
  }
  while (e > s && t[e] == m[e - 1]) {
    e--;
  }
  return e == s;
}
int main() {
  std::ios::sync_with_stdio(false);
  int n;
  cin >> n >> s1 >> s2;
  s3 = s1;
  s4 = s2;
  for (int i = 0; i < n; i++) {
    if (s1[i] != s2[i]) {
      int ans = 0;
      s3.insert(i, 1, s2[i]);
      s4.insert(i, 1, s1[i]);
      ans = is_ok(s3, s2) + is_ok(s4, s1);
      if (s3 == s4) {
        ans--;
      }
      cout << ans << endl;
      break;
    }
  }
  return 0;
}
