#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void ZZ(const char* name, Arg1&& arg1) {
  std::cerr << name << " = " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void ZZ(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  std::cerr.write(names, comma - names) << " = " << arg1;
  ZZ(comma, args...);
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  long long ans = 0;
  string s, t;
  cin >> s >> t;
  bool pre = false;
  long long a, b;
  a = b = 0;
  for (int i = 0; i < n; i++) {
    if (a <= k) a *= 2;
    if (b <= k) b *= 2;
    if (t[i] == 'b') {
      if (pre && b <= k) b++;
    }
    if (s[i] == 'a') {
      if (pre && a <= k) a++;
      if (t[i] == 'b' && !pre) pre = true;
    }
    if (pre)
      ans += min((long long)k, a + b + 2);
    else
      ans += 1;
  }
  cout << ans << '\n';
  return 0;
}
