#include <bits/stdc++.h>
using namespace std;
string a, b;
int l, r;
void go_to_end() {
  while (l < a.length() && r < b.length() && a[l] == b[r]) {
    ++l, ++r;
  }
}
int main() {
  int n;
  cin >> n;
  cin >> a >> b;
  l = 0, r = 0;
  while (l < a.length() && r < b.length() && a[l] == b[r]) {
    ++l, ++r;
  }
  if (l + 1 == a.length() && r + 1 == b.length()) {
    cout << 2;
    return 0;
  }
  int ans = 0;
  int ll = l, rr = r;
  if (a[l + 1] == b[r + 1]) {
    ++l, ++r;
    go_to_end();
    if (l == a.length()) {
      cout << 2;
      return 0;
    }
  }
  l = ll;
  r = rr;
  if (a[l + 1] == b[r]) {
    ++l;
    go_to_end();
    ++r;
    go_to_end();
    if (a.length() == l && b.length() == r) {
      ++ans;
    }
  }
  l = ll, r = rr;
  if (b[r + 1] == a[l]) {
    ++r;
    go_to_end();
    ++l;
    go_to_end();
    if (a.length() == l && b.length() == r) {
      ++ans;
    }
  }
  cout << ans;
  return 0;
}
