#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 20;
int n, k;
char a[N], b[N];
int main() {
  scanf("%d %d %s %s", &n, &k, a, b);
  long long x = 0, y = 0, ans = 0;
  for (int i = 0; i < n; i++) {
    x = (x << 1) + (b[i] - a[i]);
    ans += (min((long long)k, x + 1) - y) * (n - i);
    if (x + 1 >= k) break;
    y = x + 1;
  }
  printf("%lld\n", ans);
}
