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