#include <bits/stdc++.h>
using namespace std;
string a, b;
int n;
int calc(int i, bool ad, bool ad2) {
  int s = 0;
  if (ad) s++;
  if (ad2) s--;
  if (i == n + 1) {
    if (ad2) {
      return 1;
    } else {
      return 0;
    }
  }
  int ret = 0;
  if (a[i] == b[i + s]) {
    ret += calc(i + 1, ad, ad2);
  } else {
    if (!ad) ret += calc(i, true, ad2);
    if (!ad2) ret += calc(i + 1, ad, true);
  }
  return ret;
}
int main() {
  cin.sync_with_stdio(false);
  cout.sync_with_stdio(false);
  cin >> n;
  cin >> a >> b;
  a = " " + a + " ";
  b = " " + b + " ";
  cout << calc(1, false, false) << endl;
}
