#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
long long mod = 1000000009;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
bool is_vowel(char c) {
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y')
    return 1;
  return 0;
}
long double getDistance(long double x1, long double y1, long double x2,
                        long double y2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
long long extended_euclidean(long long a, long long b, long long &x,
                             long long &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  long long g = extended_euclidean(b, a % b, y, x);
  y -= (a / b) * x;
  return g;
}
long long power(long long base, long long p) {
  if (p == 1) return base;
  if (!p) return 1ll;
  long long ret = power(base, p / 2);
  ret *= ret;
  ret %= mod;
  if (p & 1) ret *= base;
  return ret % mod;
}
pair<long long, long long> vec(pair<long long, long long> a,
                               pair<long long, long long> b) {
  pair<long long, long long> ret =
      pair<long long, long long>(a.first - b.first, a.second - b.second);
  return ret;
}
long long getArea(pair<long long, long long> a, pair<long long, long long> b,
                  pair<long long, long long> c) {
  pair<long long, long long> x = vec(a, b);
  pair<long long, long long> y = vec(c, b);
  return abs(x.first * y.second - x.second * y.first);
}
string a, b;
bool match(int i, int k, int l) {
  while (i <= k) {
    if (a[i] != b[l]) return 0;
    i++;
    l++;
  }
  return 1;
}
int main() {
  int n;
  cin >> n >> a >> b;
  if (a == b) {
    n++;
    cout << n * 26;
  } else {
    int l = 0, r = n - 1;
    while (a[l] == b[l]) l++;
    while (a[r] == b[r]) r--;
    int sum = 0;
    if (match(l, r - 1, l + 1)) sum++;
    if (match(l + 1, r, l)) sum++;
    cout << sum;
  }
  return 0;
}
