#include <bits/stdc++.h>
using namespace std;
namespace mainns {
class Solver533E {
 public:
  void run();
};
void Solver533E::run() {
  int len;
  cin >> len;
  string s1, s2;
  cin >> s1 >> s2;
  int l = 0;
  while (s1[l] == s2[l]) ++l;
  int r = len - 1;
  while (s1[r] == s2[r]) --r;
  int ans = 0;
  if (s1.substr(l, r - l) == s2.substr(l + 1, r - l)) ++ans;
  if (s1.substr(l + 1, r - l) == s2.substr(l, r - l)) ++ans;
  cout << ans;
}
}  // namespace mainns
using CurrentSolver = mainns::Solver533E;
int main() {
  ios::sync_with_stdio(false);
  CurrentSolver().run();
  return 0;
}
