#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10, Mod = 1e9 + 7;
int n, k;
long long tot, nw;
char A[N], B[N];
int main() {
  scanf("%d%d", &n, &k);
  scanf("%s%s", &A, &B);
  if (k == 1) return !printf("%d", n);
  int _i = 0;
  while (_i < n && A[_i] == B[_i]) _i++;
  if (_i >= n) return !printf("%d", n);
  for (int i = _i; i < n; i++) A[i - _i] = A[i], B[i - _i] = B[i];
  tot += _i;
  n -= _i;
  if (k == 2) return !printf("%d", tot + n * 2);
  tot += 2;
  for (int i = 1; i < n; i++) {
    nw <<= 1;
    if (A[i] == 'a') nw++;
    if (B[i] == 'b') nw++;
    if (nw + 2 >= k) {
      tot += 1ll * (n - i) * k;
      break;
    }
    tot += nw + 2;
  }
  printf("%lld", tot);
  return (0);
}
