#include <bits/stdc++.h>
int A, B, a, b, n, i;
long long ans;
char s[500005], t[500005];
int main() {
  scanf("%d%d", &a, &b);
  scanf("%s%s", s, t);
  for (i = 0; i < a; i++) {
    if (s[i] != t[i]) break;
  }
  n = i;
  ans += n;
  if (n != a) {
    ans += std::min(b, 2);
    A = 1;
    B = 1;
    for (i = n + 1; i < a; i++) {
      if (s[i] == 'a')
        A = 2 * A;
      else
        A = (A - 1) * 2 + 1;
      if (t[i] == 'b')
        B *= 2;
      else
        B = (B - 1) * 2 + 1;
      A = std::min(b, A);
      B = std::min(b, B);
      ans += std::min(b, A + B);
    }
  }
  printf("%lld", ans);
}
