#include <bits/stdc++.h>
using namespace std;
int n;
bool same[1000000 + 5];
bool dp[1000000 + 5];
signed long long int rh[1000000 + 5], h[1000000 + 5];
map<signed long long int, bool> mp;
signed long long int pow(signed long long int base,
                         signed long long int exponent,
                         signed long long int modulus) {
  signed long long int result = 1;
  while (exponent > 0) {
    if (exponent % 2 == 1) result = (result * base) % modulus;
    exponent = exponent >> 1;
    base = (base * base) % modulus;
  }
  return result;
}
signed long long int solve(string s1, string s2) {
  for (int i = 1, j = n; i <= n; j--, ++i) {
    h[i] = (h[i - 1] + pow(26, i, 1000000007) * (s1[i] - 'a' + 1)) % 1000000007;
    rh[j] = ((s1[j] - 'a' + 1) * 26 + rh[j + 1] * 26) % 1000000007;
  }
  same[n + 1] = 1;
  for (int i = n; i >= 1; --i) same[i] = same[i + 1] & (s1[i] == s2[i]);
  dp[n + 1] = 1;
  for (int i = n; i >= 0; i--) {
    dp[i] = (dp[i + 1] & (s1[i] == s2[i + 1])) | same[i + 1];
  }
  signed long long int ans = 0;
  for (int i = 0; i <= n; ++i) {
    if (s1[i] == s2[i]) {
      if (dp[i + 1]) {
        signed long long int s =
            (h[i] + pow(26, i + 1, 1000000007) * (s2[i + 1] - 'a' + 1) +
             pow(26, i + 1, 1000000007) * rh[i + 1]) %
            1000000007;
        if (mp[s] == 0) mp[s] = 1, ans++;
      }
    } else
      break;
  }
  return ans;
}
int main() {
  cin >> n;
  string s1, s2;
  cin >> s1 >> s2;
  s1 = " " + s1;
  s2 = " " + s2;
  cout << solve(s1, s2) + solve(s2, s1);
}
