#include <bits/stdc++.h>
using namespace std;
int GCD(int a, int b) {
  if (!a) return b;
  return GCD(b % a, a);
}
bool ok(string &a, string &b) {
  for (int i = 1; i < a.size(); i++) {
    if (a[i] != b[i - 1]) return false;
  }
  return true;
}
int main() {
  clock_t startTime = clock();
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  string s;
  cin >> s;
  string t;
  cin >> t;
  int s1 = -1, s2 = -1;
  for (int i = 0; i < n; i++) {
    if (s[i] != t[i]) {
      s1 = i;
      break;
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] != t[i]) {
      s2 = i;
      break;
    }
  }
  string ss, tt;
  for (int i = s1; i <= s2; i++) {
    ss += s[i];
    tt += t[i];
  }
  cerr << ss << " " << tt << "\n";
  if (ss.size() == 1) {
    cout << "2\n";
  } else {
    int ans = ok(ss, tt) + ok(tt, ss);
    cout << ans << "\n";
  }
  clock_t endTime = clock();
  cerr << "\nTime:" << double(endTime - startTime) / CLOCKS_PER_SEC
       << " seconds\n";
  return 0;
}
