#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  bool found = false;
  bool laf = false;
  int count = 0, misl = 0, misr = 0;
  for (int i = 0; i < n; i++) {
    if (t[i] != s[i]) {
      if (!found) misl = i;
      misr = i;
      found = true;
      count++;
    }
  }
  if (count == 1)
    cout << 2;
  else {
    s.erase(misr + 1, n - misr - 1);
    t.erase(misr + 1, n - misr - 1);
    s.erase(0, misl);
    t.erase(0, misl);
    int sz = s.size();
    cout << (s.substr(0, sz - 1) == t.substr(1, sz - 1)) +
                (s.substr(1, sz - 1) == t.substr(0, sz - 1));
  }
  return 0;
}
