#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void mini(T &a, T b) {
  if (b < a) a = b;
}
template <class T>
inline void maxi(T &a, T b) {
  if (b > a) a = b;
}
int n;
string A, B;
int main() {
  cin >> n >> A >> B;
  int i = 0, j = n - 1;
  for (; i < n && A[i] == B[i]; i++)
    ;
  for (; j >= 0 && A[j] == B[j]; j--)
    ;
  if (j - i == 0)
    cout << 2 << endl;
  else {
    int num = 0;
    int k = i;
    for (k = i; k + 1 <= j && A[k] == B[k + 1]; k++)
      ;
    if (k == j) num++;
    for (k = i; k + 1 <= j && B[k] == A[k + 1]; k++)
      ;
    if (k == j) num++;
    cout << num << endl;
  }
}
