#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 50;
const int N = maxn * 25;
const long long p = 13331;
const long long mod1 = 1e9 + 7;
const long long mod2 = 19260817;
char s[maxn], t[maxn];
long long a[maxn], suf1[maxn], suf2[maxn], f[maxn];
int n;
map<pair<long long, long long>, int> mp;
map<long long, int> vis;
struct node {
  long long x, y;
  bool operator<(const node &rhs) const {
    if (x == rhs.x) return y < rhs.y;
    return x < rhs.x;
  }
} b[N];
int ans = 0, m = 0;
int judge(long long x, long long y) {
  int l = 1, r = m;
  while (l < r) {
    int mid = (l + r) >> 1;
    if (b[mid].x < x)
      l = mid + 1;
    else if (b[mid].x == x) {
      if (b[mid].y == y) return 1;
      if (b[mid].y < y)
        l = mid + 1;
      else
        r = mid;
    } else
      r = mid;
  }
  return 0;
}
void solve(char s[], int op) {
  suf1[n + 1] = suf2[n + 1] = 0;
  suf1[n] = suf2[n] = (long long)s[n];
  for (int i = n - 1; i >= 1; i--) {
    suf1[i] = ((long long)s[i] * f[n - i] % mod1 + suf1[i + 1]) % mod1;
    suf2[i] = ((long long)s[i] * a[n - i] % mod2 + suf2[i + 1]) % mod2;
  }
  long long sum1 = 0, sum2 = 0;
  for (int i = 0; i <= n; i++) {
    if (i != 0) {
      sum1 = (sum1 * p % mod1 + (long long)s[i]) % mod1;
      sum2 = (sum2 * p % mod2 + (long long)s[i]) % mod2;
    }
    for (char j = 'a'; j <= 'z'; j++) {
      long long now1 = sum1, now2 = sum2;
      now1 = (now1 * p % mod1 + (long long)j) % mod1;
      now2 = (now2 * p % mod2 + (long long)j) % mod2;
      if (i < n) {
        now1 = (now1 * f[n - i] % mod1 + suf1[i + 1]) % mod1;
        now2 = (now2 * a[n - i] % mod2 + suf2[i + 1]) % mod2;
      }
      if (op) {
        if (judge(now1, now2)) {
          if (++vis[now1] == 1) ans++;
        }
      } else {
        b[++m].x = now1;
        b[m].y = now2;
      }
    }
  }
}
int main() {
  scanf("%d", &n);
  scanf("%s", s + 1);
  scanf("%s", t + 1);
  long long sum = 0;
  f[0] = a[0] = 1;
  f[1] = a[1] = p;
  for (int i = 2; i < maxn; i++) {
    f[i] = f[i - 1] * p % mod1;
    a[i] = a[i - 1] * p % mod2;
  }
  solve(s, 0);
  sort(b + 1, b + 1 + m);
  solve(t, 1);
  printf("%d\n", ans);
}
