#include <bits/stdc++.h>
using namespace std;
const int maxN = 110100;
const long long mod1 = 1e9 + 7;
const long long mod2 = 1e9 + 9;
long long p = 31;
long long P1[maxN];
long long P2[maxN];
pair<long long, long long> H1[maxN];
pair<long long, long long> H2[maxN];
set<pair<int, int> > st;
pair<long long, long long> Hash1(int l, int r) {
  if (l == 0) {
    return H1[r];
  }
  pair<long long, long long> pp =
      make_pair(H1[r].first - H1[l - 1].first * P1[r - l + 1] + mod1 * mod1,
                H1[r].second - H1[l - 1].second * P2[r - l + 1] + mod2 * mod2);
  pp.first %= mod1;
  pp.second %= mod2;
  return pp;
}
pair<long long, long long> Hash2(int l, int r) {
  if (l == 0) {
    return H2[r];
  }
  pair<long long, long long> pp =
      make_pair(H2[r].first - H2[l - 1].first * P1[r - l + 1] + mod1 * mod1,
                H2[r].second - H2[l - 1].second * P2[r - l + 1] + mod2 * mod2);
  pp.first %= mod1;
  pp.second %= mod2;
  return pp;
}
int main() {
  int n;
  ios_base::sync_with_stdio(0);
  cin >> n;
  string s, t;
  cin >> s >> t;
  int cnt = 0, cnt1 = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == t[i]) {
      cnt++;
    } else {
      break;
    }
  }
  cnt1 = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == t[i]) {
      cnt1++;
    } else {
      break;
    }
  }
  P1[0] = 1;
  P2[0] = 1;
  for (int i = 1; i <= n; i++) {
    P1[i] = (P1[i - 1] * p) % mod1;
  }
  for (int i = 1; i <= n; i++) {
    P2[i] = (P2[i - 1] * p) % mod2;
  }
  H1[0] = make_pair(s[0] - 'a', s[0] - 'a');
  H2[0] = make_pair(t[0] - 'a', t[0] - 'a');
  for (int i = 1; i < n; i++) {
    H1[i] = make_pair(H1[i - 1].first * p + s[i] - 'a',
                      H1[i - 1].second * p + s[i] - 'a');
    H2[i] = make_pair(H2[i - 1].first * p + t[i] - 'a',
                      H2[i - 1].second * p + t[i] - 'a');
    H1[i].first %= mod1;
    H2[i].first %= mod1;
    H1[i].second %= mod2;
    H2[i].second %= mod2;
  }
  int ans = 0;
  for (int i = 1; i < n; i++) {
    int r = max(i - 1, n - cnt1 - 1);
    int l = min(i, cnt);
    if (l != i && r != i - 1) {
      continue;
    }
    if (l == i) {
      if (r == i) {
        pair<long long, long long> tmp;
        pair<long long, long long> hh = Hash1(0, i - 1);
        pair<long long, long long> hh1 = Hash1(i, n - 1);
        tmp.first =
            (hh.first * P1[n - i + 1] + hh1.first + (t[l] - 'a') * P1[n - i]) %
            mod1;
        tmp.second = (hh.second * P2[n - i + 1] + hh1.second +
                      (t[l] - 'a') * P2[n - i]) %
                     mod2;
        if (!st.count(tmp)) {
          st.insert(tmp);
          ans++;
        }
        continue;
      }
      pair<long long, long long> p1 = Hash1(i, r - 1);
      pair<long long, long long> p2 = Hash2(i + 1, r);
      if (p1 == p2) {
        pair<long long, long long> tmp;
        pair<long long, long long> hh = Hash1(0, i - 1);
        pair<long long, long long> hh1 = Hash1(i, n - 1);
        tmp.first =
            (hh.first * P1[n - i + 1] + hh1.first + (t[l] - 'a') * P1[n - i]) %
            mod1;
        tmp.second = (hh.second * P2[n - i + 1] + hh1.second +
                      (t[l] - 'a') * P2[n - i]) %
                     mod2;
        if (!st.count(tmp)) {
          st.insert(tmp);
          ans++;
        }
      }
    }
    if (r == i - 1) {
      if (l == i - 1) {
        pair<long long, long long> tmp;
        pair<long long, long long> hh = Hash1(0, i - 1);
        pair<long long, long long> hh1 = Hash1(i, n - 1);
        tmp.first = (hh.first * P1[n - i + 1] + hh1.first +
                     (t[i - 1] - 'a') * P1[n - i]) %
                    mod1;
        tmp.second = (hh.second * P2[n - i + 1] + hh1.second +
                      (t[i - 1] - 'a') * P2[n - i]) %
                     mod2;
        if (!st.count(tmp)) {
          st.insert(tmp);
          ans++;
        }
        continue;
      }
      pair<long long, long long> p1 = Hash1(l + 1, i - 1);
      pair<long long, long long> p2 = Hash2(l, i - 2);
      if (p1 == p2) {
        pair<long long, long long> tmp;
        pair<long long, long long> hh = Hash1(0, i - 1);
        pair<long long, long long> hh1 = Hash1(i, n - 1);
        tmp.first = (hh.first * P1[n - i + 1] + hh1.first +
                     (t[i - 1] - 'a') * P1[n - i]) %
                    mod1;
        tmp.second = (hh.second * P2[n - i + 1] + hh1.second +
                      (t[i - 1] - 'a') * P2[n - i]) %
                     mod2;
        if (!st.count(tmp)) {
          ans++;
          st.insert(tmp);
        }
      }
    }
  }
  int tt = 0;
  for (int i = 1; i < n; i++) {
    if (t[i] == s[i - 1]) {
      tt++;
    } else {
      break;
    }
  }
  for (int i = n - 1; i >= 1; i--) {
    if (t[i] == s[i]) {
      tt++;
    } else {
      break;
    }
  }
  if (tt >= n - 1) {
    pair<long long, long long> tmp;
    pair<long long, long long> hh1 = Hash1(0, n - 1);
    tmp.first = (hh1.first + (t[0] - 'a') * P1[n]) % mod1;
    tmp.second = (hh1.second + (t[0] - 'a') * P2[n]) % mod2;
    if (!st.count(tmp)) {
      ans++;
      st.insert(tmp);
    }
  }
  tt = 0;
  for (int i = 0; i < n - 1; i++) {
    if (t[i] == s[i]) {
      tt++;
    } else {
      break;
    }
  }
  for (int i = n - 2; i >= 0; i--) {
    if (t[i] == s[i + 1]) {
      tt++;
    } else {
      break;
    }
  }
  if (tt >= n - 1) {
    pair<long long, long long> tmp;
    pair<long long, long long> hh1 = Hash1(0, n - 1);
    tmp.first = (hh1.first * p + (t[n - 1] - 'a')) % mod1;
    tmp.second = (hh1.second * p + (t[n - 1] - 'a')) % mod2;
    if (!st.count(tmp)) {
      ans++;
      st.insert(tmp);
    }
  }
  cout << ans << endl;
  return 0;
}
