#include <bits/stdc++.h>
using ll = long long;
char a[5000001], b[5000001];
ll n, k, ans, tmp(1);
int main() {
  scanf("%lld%lld%s%s", &n, &k, a + 1, b + 1);
  for (int i = 1; i <= n; i++) {
    tmp = tmp * 2 + !!(a[i] ^ 'b') + !!(b[i] ^ 'a') - 2;
    if (tmp > k) tmp = k + 1;
    ans += (tmp < k ? tmp : k);
  }
  printf("%lld", ans);
  return 0;
}
