#include <bits/stdc++.h>
using namespace std;
char s[500005], t[500005];
long long ans;
int n, k, now, tmp;
int main() {
  scanf("%d %d\n", &n, &k);
  fread(s + 1, 1, n, stdin);
  getchar();
  fread(t + 1, 1, n, stdin);
  s[n + 1] = '#';
  if (k == 1) return printf("%d\n", n), 0;
  for (now = 1; s[now] == t[now]; now++)
    ;
  if (now > n) return printf("%d\n", n), 0;
  ans = now + 1;
  for (int i = now + 1; i <= n; i++) {
    tmp = tmp << 1;
    if (s[i] == 'a') tmp++;
    if (t[i] == 'b') tmp++;
    tmp = min(k - 2, tmp);
    ans += tmp + 2;
  }
  printf("%lld\n", ans);
}
