#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n, k;
  cin >> n >> k;
  string s, t;
  cin >> s >> t;
  ll ans = 0, cur = 1;
  for (int i = 0; i < n; i++) {
    cur *= 2;
    if (s[i] == 'b') cur--;
    if (t[i] == 'a') cur--;
    cur = min(cur, 0LL + k);
    ans += cur;
  }
  cout << (k == 1 ? n : ans) << endl;
  return 0;
}
