#include <bits/stdc++.h>
using namespace std;
long long n, m;
char a[500005], b[500005];
int main() {
  scanf("%I64d%I64d%s%s", &n, &m, a, b);
  long long x = 1, ans = 0;
  for (long long i = 0; i < n; i++) {
    x <<= 1;
    x -= a[i] == 'b';
    x -= b[i] == 'a';
    if (x > m) {
      ans += (n - i) * m;
      break;
    }
    ans += x;
  }
  cout << ans;
  return 0;
}
