#include <bits/stdc++.h>
using namespace std;
int n;
string str1, str2;
map<int, long long> dp[100011][2][2][3];
long long solve(int curr1, int curr2, int ok1, int ok2, int ok3) {
  if (curr1 == n && curr2 == n) {
    if (!ok1 && !ok2) return 26LL;
    if (ok3 > 0) {
      return 26LL - ok3;
    }
    return 1LL;
  }
  if (dp[curr1][ok1][ok2][ok3].count(curr2))
    return dp[curr1][ok1][ok2][ok3][curr2];
  long long& ret = dp[curr1][ok1][ok2][ok3][curr2];
  ret = 0;
  if (!ok2 && curr1 < str1.size()) {
    if ((curr2 < str2.size() && str1[curr1] != str2[curr2]) ||
        curr2 == str2.size())
      ret += solve(curr1 + 1, curr2, ok1, 1, ok3);
  }
  if (!ok1 && curr2 < str2.size()) {
    if ((curr1 < str1.size() && str1[curr1] != str2[curr2]) ||
        curr1 == str1.size())
      ret += solve(curr1, curr2 + 1, 1, ok2, ok3);
  }
  if (curr1 < str1.size() && curr2 < str2.size() && !ok1 && !ok2) {
    if (str1[curr1] != str2[curr2])
      ret += solve(curr1, curr2, 1, 1, 2);
    else
      ret += solve(curr1, curr2, 1, 1, 1);
  }
  if (curr1 < str1.size() && curr2 < str2.size() &&
      str1[curr1] == str2[curr2]) {
    ret += solve(curr1 + 1, curr2 + 1, ok1, ok2, ok3);
  }
  return ret;
}
int main(void) {
  ios ::sync_with_stdio(false);
  cin >> n;
  cin >> str1;
  cin >> str2;
  cout << solve(0, 0, 0, 0, 0) << "\n";
  return 0;
}
