#include <bits/stdc++.h>
using namespace std;
string a, b;
bool possible(string first, string second) {
  int counter = 0, cur = 0;
  for (int g = 0; g < second.length(); g++) {
    if (second[g] != first[counter]) {
      if (cur == 1) return false;
      counter++;
      g--;
      cur = 1;
      continue;
    }
    counter++;
  }
  return true;
}
string accumulatea(int aa, int bb) {
  string x = "";
  for (int g = aa; g <= bb; g++) x += a[g];
  return x;
}
string accumulateb(int aa, int bb) {
  string x = "";
  for (int g = aa; g <= bb; g++) x += b[g];
  return x;
}
int main() {
  int leng;
  cin >> leng;
  cin >> a >> b;
  int ans = 0;
  for (int g = 0; g < a.length(); g++) {
    if (a[g] != b[g]) {
      string pos1 = (g == 0) ? "" : accumulatea(0, g - 1);
      pos1 += b[g];
      pos1 += accumulatea(g, a.length() - 1);
      string pos2 = (g == 0) ? "" : accumulateb(0, g - 1);
      pos2 += a[g];
      pos2 += accumulateb(g, b.length() - 1);
      if (possible(pos1, a) && possible(pos1, b)) ans++;
      if (possible(pos2, a) && possible(pos2, b)) ans++;
      break;
    }
  }
  cout << ans;
  return 0;
}
