#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 7;
char s[maxn], t[maxn];
int main() {
  int n;
  long long k;
  scanf("%d%lld", &n, &k);
  scanf("%s%s", s, t);
  long long ans = 0, pre = 0;
  for (int i = 0; i < n; i++) {
    pre = min((long long)(pre * 2LL + 1LL * (t[i] - s[i])), 1LL << 40);
    ans += min(k, pre + 1);
  }
  cout << ans << endl;
  return 0;
}
