#include <bits/stdc++.h>
using namespace std;
long long dp[100011][2][2];
string a, b;
int len;
long long solve(int lengthDone, int addedA, int addedB) {
  int idxA = lengthDone - addedA;
  int idxB = lengthDone - addedB;
  if (lengthDone == len)
    return 1;
  else if (dp[lengthDone][addedA][addedB] != -1)
    return dp[lengthDone][addedA][addedB];
  long long ret = 0;
  if (a[idxA] == b[idxB])
    ret += solve(lengthDone + 1, addedA, addedB);
  else {
    if (!addedA) ret += solve(lengthDone + 1, 1, addedB);
    if (!addedB) ret += solve(lengthDone + 1, addedA, 1);
  }
  return (dp[lengthDone][addedA][addedB] = ret);
}
int main() {
  scanf("%d", &len);
  len += 1;
  cin >> a >> b;
  for (int i = 0; i <= 100010; i++)
    for (int j = 0; j < 2; j++)
      for (int k = 0; k < 2; k++) dp[i][j][k] = -1;
  cout << solve(0, 0, 0) << endl;
  return 0;
}
