#include <bits/stdc++.h>
using namespace std;
int solve(string &a, string &b) {
  int i, j, n = a.size();
  bool first = false, second = false;
  i = j = 0;
  while (i < n && j < n) {
    if (a[i] == b[j]) {
      i++;
      j++;
    } else if (!first)
      i += 1, first = true;
    else if (!second)
      j += 1, second = true;
    else
      break;
  }
  return (i == n || j == n);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  string a, b;
  cin >> n >> a >> b;
  cout << solve(a, b) + solve(b, a);
}
