#include <bits/stdc++.h>
using namespace std;
const int maxn = 233333;
char s[maxn], t[maxn];
int main() {
  int n, p, q;
  scanf("%d%s%s", &n, s, t);
  for (p = 0; s[p] == t[p]; ++p)
    ;
  for (q = n - 1; s[q] == t[q]; --q)
    ;
  int ch0 = true, ch1 = true;
  for (int i = p; i < q; ++i) {
    ch0 &= s[i] == t[i + 1];
    ch1 &= s[i + 1] == t[i];
  }
  printf("%d\n", ch0 + ch1);
}
