#include <bits/stdc++.h>
using namespace std;
int n;
string a, b;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> a >> b;
  int p1 = -1, p2 = -1;
  for (int i = 0; i < n; i++) {
    if (a[i] != b[i]) {
      p1 = i;
      break;
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] != b[i]) {
      p2 = i;
      break;
    }
  }
  string x = "", y = "";
  for (int i = p1; i <= p2; i++) {
    x += a[i];
    y += b[i];
  }
  int sol = 0;
  if (x + y.back() == x[0] + y) sol++;
  if (y[0] + x == y + x.back()) sol++;
  cout << sol << '\n';
  return 0;
}
