#include <bits/stdc++.h>
using namespace std;
int go(const string &s, const string &t, int n) {
  int i = 0, j = n - 1;
  while (i < n && s[i] == t[i]) {
    i++;
  }
  while (j >= 0 && s[j] == t[j]) {
    j--;
  }
  for (int k = i; k < j; k++) {
    if (t[k] != s[k + 1]) {
      return 0;
    }
  }
  return 1;
}
void solve() {
  int n;
  string s, t;
  cin >> n >> s >> t;
  cout << go(s, t, n) + go(t, s, n);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  solve();
  return 0;
}
