#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long X = 0, w = 0;
  char ch = 0;
  while (!isdigit(ch)) {
    w |= ch == '-';
    ch = getchar();
  }
  while (isdigit(ch)) {
    X = (X << 3) + (X << 1) + ch - '0';
    ch = getchar();
  }
  return w ? -X : X;
}
inline void print(long long x) {
  if (x < 0) x = ~x + 1, putchar('-');
  if (x > 9) print(x / 10);
  putchar(x % 10 + '0');
}
const long long N = 5e5 + 101;
long long n, k;
char a[N], b[N];
long long ans;
signed main() {
  n = read();
  k = read();
  cin >> (a + 1);
  cin >> (b + 1);
  long long cha = 0;
  for (long long i = 1; i <= n; i++) {
    if (cha + 1 >= k) {
      ans += k;
      continue;
    }
    if (a[i] == 'a' && b[i] == 'b')
      cha = cha * 2 + 1;
    else if (a[i] == b[i])
      cha = cha * 2;
    else
      cha = cha * 2 - 1;
    ans = ans + min(cha + 1, k);
  }
  cout << ans << endl;
}
