#include <bits/stdc++.h>
using namespace std;
struct S {
  int a, b;
  S() {}
  S(int _a, int _b) {
    a = _a;
    b = _b;
  }
  const bool operator<(const S &o) const { return a < o.a; }
};
string exm;
inline void exf(void) {
  cout << exm << "\n";
  exit(0);
}
template <typename T>
inline void showAll(vector<T> &v, string sep = "") {
  for (T &here : v) cout << here << sep;
}
template <typename T>
inline void showAll(T arr[], int st, int end, string sep = "") {
  for (int i = st; i <= end; i++) cout << arr[i] << sep;
}
template <typename T>
inline vector<int> int_seperation(T N, int d = 10) {
  vector<int> v;
  while (N) {
    v.push_back(N % d);
    N /= d;
  }
  reverse(v.begin(), v.end());
  return v;
}
const int SIZE = 500009;
char s[SIZE], t[SIZE];
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  scanf("%s %s", s + 1, t + 1);
  long long INF = 1e18, ans = 0, diff = 0;
  for (int i = 1; i <= n; i++) {
    diff = 2 * diff + (t[i] - s[i]);
    diff = min(diff, INF);
    ans += min(diff + 1, (long long)k);
  }
  printf("%lld\n", ans);
  return 0;
}
