#include <bits/stdc++.h>
using namespace std;
int n;
string s, t;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  cin >> s >> t;
  int x = 0;
  while (x < n && s[x] == t[x]) x++;
  if (x == n) {
    cout << n * ('z' - 'a') + 'z' - 'a' + 1 << endl;
    return 0;
  }
  int ans = 0;
  int i = x;
  int j = x + 1;
  while (j < n && i < n) {
    if (s[i] == t[j]) {
      i++;
      j++;
    } else
      i++;
  }
  if (j == n) ans++;
  i = x;
  j = x + 1;
  while (j < n && i < n) {
    if (s[j] == t[i]) {
      i++;
      j++;
    } else
      i++;
  }
  if (j == n) ans++;
  cout << ans << endl;
  return 0;
}
