#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse3,sse4,popcnt,avx,mmx,abm,tune=native")
using namespace std;
signed main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  long long n, k;
  cin >> n >> k;
  string s, t;
  cin >> s >> t;
  long long ans = 0, hv = 1;
  for (long long i = 0; i < n; i++) {
    if (hv < k) {
      hv *= 2;
      if (s[i] == t[i]) {
        hv--;
      } else if (s[i] == 'b' && t[i] == 'a') {
        hv -= 2;
      }
      hv = min(hv, k);
    }
    ans += hv;
  }
  cout << ans << "\n";
}
