#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
inline istream& operator>>(istream& fin, pair<T1, T2>& pr) {
  fin >> pr.first >> pr.second;
  return fin;
}
template <class T0, class T1, class T2>
inline istream& operator>>(istream& fin, tuple<T0, T1, T2>& t) {
  fin >> get<0>(t) >> get<1>(t) >> get<2>(t);
  return fin;
}
template <class T>
inline istream& operator>>(istream& fin, vector<T>& a) {
  if (!a.size()) {
    size_t n;
    fin >> n;
    a.resize(n);
  }
  for (auto& u : a) fin >> u;
  return fin;
}
inline bool viable(const string& w, const string& str) {
  size_t i = 0;
  while (i < str.size() && w[i] == str[i]) ++i;
  for (; i < str.size(); ++i)
    if (w[i + 1] != str[i]) return false;
  return true;
}
int probE() {
  string str0, str1;
  size_t n;
  cin >> n >> str0 >> str1;
  size_t i = 0;
  while (str0[i] == str1[i]) ++i;
  size_t j = n - 1;
  while (str0[j] == str1[j]) --j;
  set<string> a;
  a.insert(str0.substr(0, i) + str1[i] + str0.substr(i, n - i));
  a.insert(str0.substr(0, i + 1) + str1[i] + str0.substr(i + 1, n - 1 - i));
  a.insert(str0.substr(0, j) + str1[j] + str0.substr(j, n - j));
  a.insert(str0.substr(0, j + 1) + str1[j] + str0.substr(j + 1, n - 1 - j));
  ;
  int val = 0;
  for (const auto w : a)
    if (viable(w, str0) && viable(w, str1)) ++val;
  return val;
}
int main(const int argc, char* argv[]) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cout << probE();
  return EXIT_SUCCESS;
}
