#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pdd = pair<ld, ld>;
int __intend = 0;
void nextIntend() { __intend++; }
void prevIntend() { __intend--; }
string getIntend() {
  string r;
  for (int i = 0; i < __intend; ++i) {
    r += '\t';
  }
  return r;
}
template <typename T>
void print(const char s[], bool intend, T& v) {
  if (intend) cout << getIntend();
  cout << s << " = " << v << endl;
}
template <typename T, typename... TA>
void print(const char s[], bool intend, T& v, TA&... args) {
  if (intend) cout << getIntend();
  while (*s != ',') {
    if (*s != ' ') cout << *s;
    s++;
  }
  while (*s == ',' || *s == ' ') s++;
  cout << " = " << v << " | ";
  print(s, false, args...);
}
void solve() {
  int n, k;
  cin >> n >> k;
  if (k == 1) {
    cout << n << endl;
    return;
  }
  string s, t;
  cin >> s >> t;
  int st = 0;
  while (st < n && s[st] == t[st]) st++;
  ll ans = st;
  n -= st;
  s = s.substr(st);
  t = t.substr(st);
  ans += 2 * n;
  k -= 2;
  int ct = 0;
  for (int i = 1; i < n; ++i) {
    if (!k) break;
    int pt = ct;
    if (s[i] == 'a') ct++;
    if (t[i] == 'b') ct++;
    int kt = min(k, ct);
    k -= kt;
    ct += pt;
    ans += ll(kt) * (n - i);
  }
  cout << ans << endl;
}
const bool fastIO = true;
const bool withTest = false;
const bool fileIO = false;
int main() {
  if (fileIO) {
    freopen(
        "file"
        ".in",
        "r", stdin);
    freopen(
        "file"
        ".out",
        "w", stdout);
  }
  if (fastIO) {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
  }
  if (withTest) {
    int t;
    cin >> t;
    while (t--) solve();
  } else
    solve();
}
