#include <bits/stdc++.h>
using namespace std;
long long ans, res = 1, n, k;
char a[500010], b[500010];
int main() {
  cin >> n >> k >> a + 1 >> b + 1;
  for (long long i = 1; i <= n; i++) {
    res <<= 1;
    if (a[i] == 'b') res--;
    if (b[i] == 'a') res--;
    if (res >= k) res = k + 1;
    ans += min(res, k);
  }
  printf("%lld", ans);
}
