#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
const int mod = 998244353;
const long long inf = 1e18 + 7;
string second, t;
long long ans, curr, n, k;
int main() {
  cin >> n >> k;
  cin >> second;
  cin >> t;
  for (int i = 0; i <= n - 1; i++) {
    curr = min(2 * curr + t[i] - second[i], k);
    ans += min(k, curr + 1);
  }
  cout << ans << endl;
  return 0;
}
