#include <bits/stdc++.h>
using namespace std;
long long int ppow[200001];
string s, t;
long long int a[200000], b[200000];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, len, len1, val, val1, val2, val3, index1 = -1, index2 = -1,
                                                     ans = 0, flag = 1, i, j, k;
  cin >> n;
  cin >> s;
  cin >> t;
  len = s.length();
  len1 = t.length();
  ppow[0] = 1;
  for (i = 1; i <= 200000; i++) ppow[i] = (765404567 * ppow[i - 1]) % 999999937;
  for (i = 0; i < len; i++) {
    if (s[i] != t[i]) {
      index1 = i;
      break;
    }
  }
  for (i = len - 1; i >= 0; i--) {
    if (s[i] != t[i]) {
      index2 = i;
      break;
    }
  }
  if (index1 == -1) {
    cout << 26 * (len + 1);
    return 0;
  }
  if (index1 == index2) {
    cout << 2;
    return 0;
  }
  for (i = index1; i < index2; i++) {
    if (s[i] != t[i + 1]) {
      flag = 0;
      break;
    }
  }
  ans += flag;
  flag = 1;
  for (i = index1; i < index2; i++) {
    if (s[i + 1] != t[i]) {
      flag = 0;
      break;
    }
  }
  ans += flag;
  cout << ans;
  return 0;
}
