#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string a, b;
  cin >> a >> b;
  int sptr = 0, lptr = n - 1;
  for (sptr = 0; sptr < n; sptr++)
    if (a[sptr] != b[sptr]) break;
  for (lptr = n - 1; lptr >= 0; lptr--)
    if (a[lptr] != b[lptr]) break;
  string mida = a.substr(sptr, lptr - sptr + 1),
         midb = b.substr(sptr, lptr - sptr + 1);
  set<string> ans;
  string tmpa = " ", rtmpb = " ", tmpb, rtmpa;
  for (int i = 0; i < mida.length(); i++)
    tmpa += " ", tmpa[tmpa.length() - 1] = mida[i], rtmpb += " ",
                                      rtmpb[rtmpb.length() - 1] = midb[i];
  tmpb = midb, tmpb += " ", rtmpa = mida, rtmpa += " ";
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < 26; j++) {
      tmpa[0] = i + 'a';
      tmpb[tmpb.length() - 1] = j + 'a';
      if (tmpa == tmpb) ans.insert(tmpb);
      rtmpb[0] = i + 'a';
      rtmpa[rtmpa.length() - 1] = j + 'a';
      if (rtmpa == rtmpb) ans.insert(rtmpb);
    }
  }
  cout << (int)ans.size() << endl;
}
