#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e5 + 10;
int n;
long long k;
char s[MAXN], t[MAXN];
long long dp[MAXN];
int main() {
  while (~scanf("%d %I64d", &n, &k)) {
    scanf("%s", s);
    scanf("%s", t);
    memset(dp, 0, sizeof(dp));
    dp[0] = 1;
    long long ans = 0;
    for (int i = 1; i <= n; i++) {
      dp[i] = dp[i - 1] * 2;
      if (s[i - 1] == 'b') dp[i]--;
      if (t[i - 1] == 'a') dp[i]--;
      if (dp[i] >= k) {
        dp[i] = k;
        ans += (n - i) * k;
        break;
      }
    }
    for (int i = 1; i <= n; i++) ans += dp[i];
    printf("%I64d\n", ans);
  }
  return 0;
}
