#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j;
  cin >> n;
  string s, t;
  cin >> s;
  cin >> t;
  for (i = 0; i < n; i++) {
    if (s[i] != t[i]) {
      s = s.substr(i, n - i);
      t = t.substr(i, n - i);
      break;
    }
  }
  for (i = s.length() - 1; i >= 0; i--) {
    if (s[i] != t[i]) {
      s = s.substr(0, i + 1);
      t = t.substr(0, i + 1);
      break;
    }
  }
  string x, y;
  j = 0;
  x = s[0] + t;
  y = s + t[t.length() - 1];
  if (x == y) j++;
  x = y = "";
  x = t[0] + s;
  y = t + s[s.length() - 1];
  if (x == y) j++;
  cout << j << endl;
  return 0;
}
