#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long f = 1, x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int maxn = 5e5 + 5;
char st1[maxn], st2[maxn];
long long ans = 0, pre = 0;
int n, k;
int main() {
  n = read(), k = read();
  scanf("%s", st1);
  scanf("%s", st2);
  for (int i = 0; i <= n - 1; i++) {
    pre = min(pre * 2 + (int)(st2[i] - st1[i]), 1ll << 36);
    ans += min(pre + 1, (long long)k);
  }
  cout << ans << endl;
  return 0;
}
