#include <bits/stdc++.h>
using namespace std;
const int maxs = 5e5 + 10;
char a[maxs], b[maxs];
int main() {
  long long n, k;
  long long ans = 0, s = 1;
  scanf("%lld%lld", &n, &k);
  scanf("%s%s", a, b);
  if (k == 1) {
    printf("%d\n", n);
    return 0;
  }
  for (int i = 0; i < n; i++) {
    s *= 2;
    if (a[i] == b[i])
      s--;
    else if (a[i] > b[i])
      s -= 2;
    s = min(s, k);
    ans += s;
  }
  printf("%lld\n", ans);
  return 0;
}
