#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int main() {
  int n;
  string a, b;
  cin >> n;
  cin >> a >> b;
  int cnt = 0;
  int i, j, k;
  for (i = 0; a[i] == b[i]; i++)
    ;
  for (j = n - 1; a[j] == b[j]; j--)
    ;
  for (k = i; a[k] == b[k + 1] && k < j; k++)
    ;
  if (k == j) cnt++;
  for (k = i; a[k + 1] == b[k] && k < j; k++)
    ;
  if (k == j) cnt++;
  cout << cnt << endl;
  return 0;
}
