#include <bits/stdc++.h>
using namespace std;
const long long EPS = (long long)5e18;
const int eps = 1e9 + 7;
const long double inf = 1e-10;
bool f(string &s, string &t, int i, int j) {
  for (int q = i; q < j; ++q) {
    if (q + 1 == t.size()) {
      break;
    }
    if (s[q] != t[q + 1]) {
      return 0;
    }
  }
  return 1;
}
int main() {
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  if (s == t) {
    cout << n + 1;
    return 0;
  }
  int i = 0, j = n - 1;
  while (s[i] == t[i]) {
    ++i;
  }
  while (s[j] == t[j]) {
    --j;
  }
  int cnt = f(s, t, i, j) + f(t, s, i, j);
  cout << cnt;
  return 0;
}
