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