#include <bits/stdc++.h>
using namespace std;
const long long k = 31;
const long long MOD = 18014398241046527;
long long mul(long long a, long long b) {
  return (__int128)a * (__int128)b % MOD;
}
struct hash_string {
  vector<long long> pref;
  hash_string(string a) {
    pref.resize(a.size() + 1);
    pref[0] = 0;
    long long temp = 1;
    for (int i = 0; i < a.size(); ++i) {
      pref[i + 1] = (pref[i] + mul((a[i] - 'a'), temp)) % MOD;
      temp = mul(temp, k);
    }
  }
  long long hashing(int ind) {
    if (ind == pref.size() - 2) return mul(pref[ind], k);
    return ((pref.back() - pref[ind + 1] + MOD) % MOD + mul(pref[ind], k)) %
           MOD;
  }
};
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  string s1, s2;
  cin >> n >> s1 >> s2;
  hash_string h1(s1), h2(s2);
  int ans = 0;
  for (int i = 0; i < n; ++i)
    if (s1[i] != s2[i]) {
      for (int j = i; j < n; ++j) {
        if (h1.hashing(i) == h2.hashing(j) && (i == j || s2[j] != s2[j - 1])) {
          ++ans;
        }
        if (h1.hashing(j) == h2.hashing(i) && (i == j || s1[j] != s1[j - 1])) {
          ++ans;
        }
      }
      cout << ans;
      break;
    }
}
