#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  string a, b;
  cin >> a >> b;
  long long l = n, r = -1;
  for (long long i = 0; i < n; i++) {
    if (a[i] != b[i]) {
      l = min(l, i);
      r = max(r, i);
    }
  }
  long long ans = (a.substr(l, r - l) == b.substr(l + 1, r - l)) +
                  (a.substr(l + 1, r - l) == b.substr(l, r - l));
  cout << ans << "\n";
}
