#include <bits/stdc++.h>
using namespace std;
const int inf = numeric_limits<int>::max();
const long long linf = numeric_limits<long long>::max();
const int maxn = 1000000;
double EPS = 1e-12;
double PI = 2 * acos(0);
int main() {
  string s, t;
  int l, r, n;
  cin >> n >> s >> t;
  l = 0;
  r = n - 1;
  while (l < n && s[l] == t[l]) ++l;
  while (r > -1 && s[r] == t[r]) --r;
  if (r == l)
    printf("2");
  else {
    int len = r - l;
    set<string> poss;
    if (s.substr(l, len) == t.substr(l + 1, len))
      poss.insert(t.substr(l, len + 1) + s[r]);
    if (s.substr(l + 1, len) == t.substr(l, len))
      poss.insert(s.substr(l, len + 1) + t[r]);
    printf("%d", (int)poss.size());
  }
  return 0;
}
