#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 5;
const int mod = (int)1e9 + 7;
int n, ans;
string a, b, s, z;
inline void solve() {
  cin >> n >> a >> b;
  for (int i = 0; i < n; i++) {
    if (a[i] != b[i]) {
      a = a.substr(i);
      b = b.substr(i);
      break;
    }
  }
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());
  n = a.size();
  for (int i = 0; i < n; i++) {
    if (a[i] != b[i]) {
      a = a.substr(i);
      b = b.substr(i);
      break;
    }
  }
  n = a.size() - 1;
  if (a.substr(1) == b.substr(0, n)) {
    ans++;
  }
  if (a.substr(0, n) == b.substr(1)) {
    ans++;
  }
  printf("%d\n", ans);
}
int tests = 1;
int main() {
  while (tests--) {
    solve();
  }
  return 0;
}
