#include <bits/stdc++.h>
using namespace std;
int n, ans;
string a, b, a2, b2;
int main() {
a:
  cin >> n >> a >> b;
  int m1 = n + 5, m2;
  for (int i = 0; i < n; i++) {
    if (a[i] != b[i]) m1 = min(m1, i), m2 = i;
  }
  a2 = a.substr(m1, m2 - m1 + 1);
  b2 = b.substr(m1, m2 - m1 + 1);
  int yes1 = 1;
  for (int i = 0; i < ((int)(a2.size())) - 1 and yes1; i++) {
    if (a2[i] != b2[i + 1]) yes1 = 0;
  }
  ans = 0;
  ans += yes1;
  int yes2 = 1;
  for (int i = 0; i < ((int)(a2.size())) - 1 and yes2; i++) {
    if (b2[i] != a2[i + 1]) yes2 = 0;
  }
  ans += yes2;
  cout << ans << '\n';
}
