#include <bits/stdc++.h>
using namespace std;
int n, c, res;
string s, p;
int main() {
  cin >> n;
  cin >> s >> p;
  for (int i = 0; i < n; i++, c++) {
    if (s[i] != p[i]) {
      break;
    }
  }
  s.erase(0, c);
  p.erase(0, c);
  n -= c;
  c = 0;
  for (int i = 1; i <= n; i++, c++) {
    if (s[n - i] != p[n - i]) break;
  }
  s.erase(n - c, n);
  p.erase(n - c, n);
  n = s.size();
  string s1 = s, s2 = s, p1 = p, p2 = p;
  s1.erase(0, 1);
  s2.erase(n - 1, n);
  p1.erase(n - 1, n);
  p2.erase(0, 1);
  if (s1 == p1) res++;
  if (s2 == p2) res++;
  cout << res << endl;
  return 0;
}
