#include <bits/stdc++.h>
using namespace std;
char s1[100001], s2[100001];
int n, l, r, ans;
int main() {
  scanf("%d", &n);
  scanf("%s", s1);
  scanf("%s", s2);
  l = 0;
  r = n - 1;
  while (s1[l] == s2[l]) l++;
  while (s1[r] == s2[r]) r--;
  if (l == r) {
    printf("2\n");
    return 0;
  }
  bool q = 1;
  for (int i = l + 1; i <= r; i++)
    if (s1[i] != s2[i - 1]) {
      q = 0;
      break;
    }
  if (q) ans++;
  q = 1;
  for (int i = l + 1; i <= r; i++)
    if (s2[i] != s1[i - 1]) {
      q = 0;
      break;
    }
  if (q) ans++;
  printf("%d\n", ans);
  return 0;
}
