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