#include <bits/stdc++.h>
using namespace std;
long long n, k;
string s, t;
long long ans[500005];
int main() {
  cin >> n >> k;
  cin >> s >> t;
  long long sum = 0;
  int lo1 = 0, hi1 = 0, lo2 = 0, hi2 = 0;
  string low, high;
  long long total = 1;
  for (int i = 0; i < n; i++) {
    long long next = 0;
    if (total == 1) {
      if (s[i] != t[i]) {
        next += 2;
      } else {
        next++;
      }
    } else {
      next += (total - 2) * 2;
      if (s[i] == 'b') {
        next++;
      } else
        next += 2;
      if (t[i] == 'a')
        next++;
      else
        next += 2;
    }
    sum += min(next, k);
    total = min(next, k);
  }
  cout << sum;
}
