#include <bits/stdc++.h>
using namespace std;
string get1(string s, string t, int pos) {
  string ans = "";
  for (int i = 0; i < pos; i++) ans += s[i];
  ans += t[pos];
  for (int i = pos; i < s.size(); i++) ans += s[i];
  return ans;
}
string get2(string s, string t, int pos) {
  string ans = "";
  for (int i = 0; i <= pos; i++) ans += t[i];
  ans += s[pos];
  for (int i = pos + 1; i < s.size(); i++) ans += t[i];
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  int first = -1, last = -1;
  for (int i = 0; i < n; i++)
    if (s[i] != t[i]) last = i;
  for (int i = n - 1; i >= 0; i--)
    if (s[i] != t[i]) first = i;
  if (first == -1) {
    int ans = 26 * (n + 1);
    char c = '#';
    int cnt = 0;
    for (int i = 0; i < n; i++)
      if (s[i] == c)
        cnt++;
      else {
        c = s[i];
        ans -= cnt;
        cnt = 1;
      }
    ans -= cnt;
    cout << ans << endl;
  } else if (first == last)
    cout << 2 << endl;
  else {
    set<string> st;
    string su = get1(s, t, first);
    string sd = get2(s, t, last);
    if (su == sd) st.insert(su);
    swap(s, t);
    su = get1(s, t, first);
    sd = get2(s, t, last);
    if (su == sd) st.insert(sd);
    cout << st.size() << endl;
  }
  return 0;
}
