#include <bits/stdc++.h>
using namespace std;
signed main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  string s, t;
  cin >> s >> t;
  long long ns = 0;
  long long ans = 0;
  long long num = 1;
  for (long long i = 0; i < n; i++) {
    num = (num * 2);
    if (s[i] == 'b') num--;
    if (t[i] == 'a') num--;
    num = min(num, k + 1);
    ans += min(num, k);
  }
  cout << ans << endl;
}
