#include <bits/stdc++.h>
using namespace std;
string s, t;
long long n;
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> s >> t;
  int vtl, vtr;
  string prefix = "";
  for (long long i = (0), _b = (n - 1); i <= _b; i++)
    if (s[i] == t[i])
      prefix += s[i];
    else {
      vtl = i;
      break;
    }
  string suffix = "";
  for (long long i = (n - 1), _b = (1); i >= _b; i--)
    if (s[i] == t[i])
      suffix += s[i];
    else {
      vtr = i;
      break;
    }
  int res = 0;
  if (s.substr(vtl, vtr - vtl) == t.substr(vtl + 1, vtr - vtl)) res++;
  if (t.substr(vtl, vtr - vtl) == s.substr(vtl + 1, vtr - vtl)) res++;
  cout << res;
  return 0;
}
