#include <bits/stdc++.h>
using namespace std;
char a[1000005];
char b[1000005];
int main(void) {
  int n;
  cin >> n >> (a + 1) >> (b + 1);
  int ok = 0;
  for (int i = 1; i <= n; ++i) ok += a[i] != b[i];
  if (!ok) return cout << "26\n", 0;
  if (ok == 1) return cout << "2\n", 0;
  string k = "", l = "";
  for (int i = 1; i <= n; ++i) k += a[i];
  for (int i = 1; i <= n; ++i) l += b[i];
  int cnt = 0, ans = 0;
  while (k[cnt] == l[cnt]) ++cnt;
  k.insert(k.begin() + cnt, l[cnt]);
  while (k[cnt] == l[cnt]) ++cnt;
  l.insert(l.begin() + cnt, k[cnt]);
  ans += (k == l);
  k = "";
  l = "";
  for (int i = 1; i <= n; ++i) k += a[i];
  for (int i = 1; i <= n; ++i) l += b[i];
  cnt = 0;
  while (k[cnt] == l[cnt]) ++cnt;
  l.insert(l.begin() + cnt, k[cnt]);
  while (k[cnt] == l[cnt]) ++cnt;
  k.insert(k.begin() + cnt, l[cnt]);
  ans += (k == l);
  return cout << ans << '\n', 0;
}
