#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
inline long long int max(long long int a, long long int b) {
  return ((a > b) ? a : b);
}
inline long long int min(long long int a, long long int b) {
  return ((a > b) ? b : a);
}
inline long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  a %= b;
  return gcd(b, a);
}
bool calc(string s, string t, long long int n) {
  long long int i = 0, j = n - 1;
  while (s[i] == t[i]) i++;
  while (s[j] == t[j]) j--;
  while (s[i + 1] == t[i]) i++;
  return i >= j;
}
void sol() {
  long long int n, i, pos1 = -1, pos2 = -1, j;
  string s, t;
  cin >> n >> s >> t;
  cout << calc(s, t, n) + calc(t, s, n) << endl;
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  sol();
}
