#include <bits/stdc++.h>
using namespace std;
char a[500500], b[500500];
long long i, n, k, ans, sum = 2;
int main() {
  scanf("%lld%lld%s%s", &n, &k, a + 1, b + 1);
  for (i = 1; i <= n; sum <<= 1, i++)
    sum -= (b[i] == 'a') + (a[i] == 'b'),
        ans += min(sum = (sum > k) ? k + 1 : sum, k);
  printf("%lld", ans);
  return 0;
}
