#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n;
  cin >> n;
  string a, b;
  cin >> a >> b;
  int pos1 = n, pos2 = -1;
  for (int i = 0; i < n; i++) {
    if (a[i] != b[i]) {
      pos1 = i;
      break;
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] != b[i]) {
      pos2 = i;
      break;
    }
  }
  string c, d;
  for (int i = pos1; i <= pos2; i++) {
    c.push_back(a[i]), d.push_back(b[i]);
  }
  int ans = 0;
  if (pos1 == pos2) {
    ans = 2;
  } else {
    if (c.substr(1, pos2 - pos1) == d.substr(0, pos2 - pos1)) ans++;
    if (c.substr(0, pos2 - pos1) == d.substr(1, pos2 - pos1)) ans++;
  }
  cout << ans;
  return 0;
}
