#include <bits/stdc++.h>
using namespace std;
const int N = 500005;
int n, k;
char a[N], b[N];
int main() {
  scanf("%d%d%s%s", &n, &k, a, b);
  long long cur = 1, ans = 0;
  if (k == 1) {
    cout << n << endl;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    cur *= 2;
    if (a[i] != 'a') --cur;
    if (b[i] != 'b') --cur;
    cur = min(cur, k * 1ll);
    ans += cur;
  }
  cout << ans << endl;
  return 0;
}
