#include <bits/stdc++.h>
template <typename T>
inline T Abs(const T a) {
  return a < 0 ? -a : a;
}
template <typename T>
inline T Min(const T a, const T b) {
  return a < b ? a : b;
}
template <typename T>
inline T Max(const T a, const T b) {
  return a > b ? a : b;
}
template <typename T>
inline void UpdateMin(T& a, const T b) {
  a = Min(a, b);
}
template <typename T>
inline void UpdateMax(T& a, const T b) {
  a = Max(a, b);
}
static const double eps = 1.0e-09;
template <typename T>
inline bool IsEqual(const T a, const T b) {
  return Abs(a - b) < eps;
}
template <typename T>
inline bool IsGreater(const T a, const T b) {
  return a > b + eps;
}
template <typename T>
inline bool IsLess(const T a, const T b) {
  return a + eps < b;
}
template <typename T>
inline std::string ToStr(const T& val) {
  std::ostringstream ostr;
  ostr << val;
  return ostr.str();
}
template <typename T>
inline bool FromStr(const std::string& str, T& val) {
  std::istringstream istr(str);
  istr >> val;
  return !!istr;
}
template <typename T>
inline std::istream& operator>>(std::istream& ist, std::vector<T>& data) {
  for (size_t i = 0; i < data.size(); i++) {
    ist >> data[i];
  }
  return ist;
}
template <typename T>
inline std::ostream& operator<<(std::ostream& ost, const std::vector<T>& data) {
  for (size_t i = 0; i < data.size(); i++) {
    if (i != 0) {
      ost << ' ';
    }
    ost << data[i];
  }
  return ost;
}
template <size_t id>
class StopWatch {};
size_t GetFirstDiff(const std::string& s, const std::string& t) {
  ;
  for (size_t i = 0; i < s.size(); i++) {
    if (s[i] != t[i]) return i;
  };
  return s.size();
}
const std::string Empty = "";
std::string Try(const std::string& s, const std::string& t,
                const size_t firstDiffIndex) {
  ;
  const char tc = t[firstDiffIndex];
  const std::string ms = s.substr(0, firstDiffIndex) + tc +
                         s.substr(firstDiffIndex, s.size() - firstDiffIndex);
  const std::string partMs = ms.substr(0, s.size());
  if (partMs == t) return ms;
  const size_t nextDiff = GetFirstDiff(ms, t + ' ');
  ;
  const char sc = ms[nextDiff];
  const std::string mt =
      t.substr(0, nextDiff) + sc + t.substr(nextDiff, t.size() - nextDiff);
  if (ms == mt) return ms;
  return Empty;
}
bool Solve(std::istream& ist, std::ostream& ost, const bool multipleTestMode) {
  StopWatch<1> sw;
  (void)sw;
  size_t n;
  ist >> n;
  if (multipleTestMode && !ist) return false;
  std::string s, t;
  ist >> s >> t;
  const size_t firstDiffIndex = GetFirstDiff(s, t);
  std::set<std::string> answers;
  const std::string s1 = Try(s, t, firstDiffIndex);
  const std::string s2 = Try(t, s, firstDiffIndex);
  if (!s1.empty()) answers.insert(s1);
  if (!s2.empty()) answers.insert(s2);
  ost << answers.size() << std::endl;
  return multipleTestMode;
}
int main(int argc, const char* argv[]) {
  std::ios_base::sync_with_stdio(false);
  std::istream* ist = &std::cin;
  std::ostream* ost = &std::cout;
  std::unique_ptr<std::istream> fileInput;
  if (argc > 1) {
    fileInput.reset(new std::ifstream(argv[1]));
    if (!(*fileInput)) {
      std::cout << "File not found: " << argv[1] << std::endl;
    }
    ist = fileInput.get();
  }
  Solve(*ist, *ost, false);
}
