#include <bits/stdc++.h>
using namespace std;
template <typename C>
void MA(C& a, C b) {
  if (a < b) a = b;
}
template <typename C>
void MI(C& a, C b) {
  if (a > b) a = b;
}
int n;
char t[100101], s[100101];
int main() {
  scanf("%d", &n);
  scanf("%s%s", t, s);
  int a = 0;
  while (t[a] == s[a]) a++;
  int b = 0;
  while (t[n - b - 1] == s[n - b - 1]) b++;
  int wyn = 0;
  int il = n - a - b - 1;
  bool cz = 1;
  for (int i = 0; i < il; i++)
    if (t[a + i] != s[a + i + 1]) cz = 0;
  if (cz) wyn++;
  cz = 1;
  for (int i = 0; i < il; i++)
    if (t[a + i + 1] != s[a + i]) cz = 0;
  if (cz) wyn++;
  printf("%d\n", wyn);
}
