#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 10, MOD = 1e9 + 7;
long long n, c, prefix[500000], sum;
string s, t;
int main() {
  cin >> n >> c;
  cin >> s >> t;
  if (s[0] != t[0])
    prefix[0] = 2;
  else
    prefix[0] = 1;
  sum += n * min(prefix[0], c);
  c -= min(prefix[0], c);
  for (long long i = 1; i < n; i++) {
    if (c == 0) break;
    prefix[i] = 2 * prefix[i - 1];
    if (t[i] == 'a') prefix[i]--;
    if (s[i] == 'b') prefix[i]--;
    sum += (n - i) * min(prefix[i] - prefix[i - 1], c);
    c -= min(prefix[i] - prefix[i - 1], c);
  }
  cout << sum;
  return 0;
}
