#include <bits/stdc++.h>
using namespace std;
int n, dp[100009][3][2][2];
string a, b;
int Solve(int pos, int w, int aa, int bb) {
  if (aa > 1 || bb > 1) return 0;
  if (pos == n) return 1;
  int &res = dp[pos][w][aa][bb];
  if (res != -1) return res;
  res = 0;
  if (a[pos] == b[pos + bb - w]) {
    res += Solve(pos + 1, w, aa, bb);
  } else {
    res += Solve(pos, w, aa, bb + 1);
    res += Solve(pos + 1, 1, aa + 1, bb);
  }
  return res;
}
int main() {
  cin >> n;
  cin >> a >> b;
  memset(dp, -1, sizeof(dp));
  cout << Solve(0, 0, 0, 0) << endl;
  return 0;
}
