#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
int n, ans;
string s, t;
int main() {
  scanf("%d", &n);
  cin >> s >> t;
  if (s != t) {
    int i1 = 0, i2 = n - 1;
    while (s[i1] == t[i1]) i1++;
    while (s[i2] == t[i2]) i2--;
    s = s.substr(i1, i2 - i1 + 1);
    t = t.substr(i1, i2 - i1 + 1);
    if (t[0] + s == t + s[s.length() - 1]) ans++;
    if (s[0] + t == s + t[t.length() - 1]) ans++;
    printf("%d\n", ans);
  } else {
    printf("%d\n", 26 * (n + 1));
  }
}
