#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void setmin(T &x, T y) {
  if (y < x) x = y;
}
template <typename T>
inline void setmax(T &x, T y) {
  if (y > x) x = y;
}
template <typename T>
inline T gcd(T a, T b) {
  while (b) swap(a %= b, b);
  return a;
}
const int MAX = (1e6);
const int INF = 1e9 + 7;
const long long BIG_INF = 1e18 + 5;
long long n, k;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  string a, b;
  cin >> a >> b;
  int odp = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] != b[i]) {
      bool same = 1;
      for (int j = i + 1; j < n; j++) {
        if (a[j] != b[j]) {
          same = 0;
          break;
        }
      }
      if (same) {
        cout << 2;
        return 0;
      }
      bool same2 = 1;
      if (a[i] == b[i + 1]) {
        int ida = i + 1;
        int idb = i + 2;
        while (idb < n && a[ida] == b[idb]) {
          ida++;
          idb++;
        }
        for (int i = idb; i < n; i++) {
          if (a[i] != b[i]) {
            odp--;
            break;
          }
        }
        odp++;
      }
      if (b[i] == a[i + 1]) {
        int ida = i + 2;
        int idb = i + 1;
        while (ida < n && a[ida] == b[idb]) {
          ida++;
          idb++;
        }
        for (int i = ida; i < n; i++) {
          if (a[i] != b[i]) {
            odp--;
            break;
          }
        }
        odp++;
      }
      cout << odp;
      return 0;
    }
  }
}
