#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100005;
char s[MAX_N];
char t[MAX_N];
char w[MAX_N];
int n;
int sol;
set<string> S;
void die() {
  printf("%d\n", S.size());
  exit(0);
}
bool next_w() {
  static int l = 0;
  static char c = 'a';
  if (c > 'z') {
    c = 'a';
    l++;
    w[l - 1] = w[l];
  }
  if (l > n) return false;
  w[l] = c++;
  return true;
}
void check() {
  int i;
  for (i = 0; i < n; i++) {
    if (w[i] != t[i]) break;
  }
  for (i++; i < n + 1; i++) {
    if (w[i] != t[i - 1]) return;
  }
  S.insert(w);
}
int equal(char* a, char* b, int len) { return memcmp(a, b, len) == 0; }
int main() {
  scanf("%d", &n);
  scanf("%s", s);
  scanf("%s", t);
  int start = 0, end = n - 1;
  while (s[start] == t[start]) start++;
  while (s[end] == t[end]) end--;
  int sol = equal(s + start, t + start + 1, end - start) +
            equal(s + start + 1, t + start, end - start);
  printf("%d\n", sol);
}
