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