#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const int MOD = 1e9 + 7;
const int N = 0;
int n;
string s1, s2;
int solve() {
  int dif = 0;
  for (auto i = 0; i < n; i++) dif += s1[i] != s2[i];
  if (dif == 1) return 2;
  int ans = 0;
  for (auto j = 0; j <= 1; j++) {
    int L = 0;
    while (s1[L] == s2[L]) L++;
    int R = L + 1;
    while (R < n && s1[R - 1] == s2[R]) R++;
    while (R < n && s1[R] == s2[R]) R++;
    ans += (R == n);
    swap(s1, s2);
  }
  return ans;
}
int main() {
  cin >> n >> s1 >> s2;
  cout << solve();
}
