#include <bits/stdc++.h>
const int N = 500000;
int n, k;
char s[N + 1], t[N + 1];
int main() {
  scanf("%d%d%s%s", &n, &k, s, t);
  int r = 0;
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    if (r < k) {
      r *= 2;
      r += t[i] - s[i];
    }
    r = std::min(r, k);
    ans += r == k ? r : r + 1;
  }
  printf("%lld\n", ans);
  return 0;
}
