#include <bits/stdc++.h>

#define int long long

using namespace std;

const int MAXN = 5e6 + 100;

#ifdef LOCAL
#include "/media/brayand/BrayanD/debugger.h"
#else
template<typename T, typename... Args>
void db(T &data, Args... args){}
#endif

int qpow(int a, int b)
{
	int res = 1;
	while(b)
	{
		if(b&1)res = res*a;
		a = a*a;
		b /= 2;
	}
	return res;
}

int T[MAXN][2];

bool mk[MAXN];

int contg = 0;

vector<int> vect;

int res = 0;

void DFS(int nodo, int lvl)
{
	if(!mk[nodo])vect.push_back(lvl), db(nodo);
	else res++;

	if(T[nodo][0])
	{
		DFS(T[nodo][0], lvl-1);
	}
	if(T[nodo][1])
	{
		DFS(T[nodo][1], lvl-1);
	}
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int N, K;
    cin >> N >> K;

    string A, B;
    cin >> A >> B;

    int pe = -1;

    for(int i = 0 ; i < N ; i++)
    {
    	if(A[i] == B[i])pe++;
    	else break;
    }

    db(pe);

    int pt = 0;
    mk[pt] = true;

    for(int i = 0 ; i < N ; i++)
    {
    	if(A[i] == 'a')
    	{
    		if(T[pt][0] == 0)T[pt][0] = ++contg;
    		if(i > pe && T[pt][1] == 0)T[pt][1] = ++contg;

    		pt = T[pt][0];
    		mk[pt] = true;
    	}
    	else
    	{
    		if(T[pt][1] == 0)T[pt][1] = ++contg;

    		pt = T[pt][1];
    		mk[pt] = true;
    	}
    }

    pt = 0;

    for(int i = 0 ; i < N ; i++)
    {
    	if(B[i] == 'a')
    	{
    		if(T[pt][0] == 0)T[pt][0] = ++contg;

    		pt = T[pt][0];
    		mk[pt] = true;
    	}
    	else
    	{
    		if(i > pe && T[pt][0] == 0)T[pt][0] = ++contg;
    		if(T[pt][1] == 0)T[pt][1] = ++contg;

    		pt = T[pt][1];
    		mk[pt] = true;
    	}
    }

    DFS(0,N);

    // vect.push_back(0);
    // vect.push_back(0);

    db(vect);
    res--;
    db(res);

    sort(vect.begin(), vect.end());
    reverse(vect.begin(), vect.end());

    for(int i = 0 ; i < vect.size() ; i++)
    {
    	vect[i]++;
    }

    vector<int> vvv(vect.size());

    priority_queue<pair<int,int>> Q;

    for(int i = 0 ; i < vvv.size() ; i++)
    {
    	if(vvv[i] == 0)
    	{
			Q.push({vect[i], i});
		}
		else
		{
			Q.push({(vect[i] - vvv[i]) * qpow(2,vvv[i]-1), i});
		}
    }

    db(Q);

    if(K == 1)
    {
    	cout << N << '\n';
    	return 0;
    }

    if(K == 2)
    {
    	cout << res << '\n';
    	return 0;
    }

    K-=2;

    while(Q.size())
    {
    	pair<int,int> pp = Q.top();
    	Q.pop();

    	int tam = 0;

    	if(vvv[pp.second] == 0)tam = 1;
    	else tam = qpow(2,vvv[pp.second]-1);

    	if(tam < K)
    	{
    		K -= tam;
    		res += pp.first;
    		vvv[pp.second]++;
    		Q.push({(vect[pp.second] - vvv[pp.second]) * qpow(2,vvv[pp.second]-1), pp.second});
    	}
    	else
    	{
    		if(vvv[pp.second] == 0)res += vect[pp.second];
    		else res += (vect[pp.second] - vvv[pp.second]) * (K);
    		break;
    	}
    	db(Q);
    }

    cout << res << '\n';
    return 0;
}


#include <bits/stdc++.h>

#define int long long

using namespace std;

const int MAXN = 5e6 + 100;

#ifdef LOCAL
#include "/media/brayand/BrayanD/debugger.h"
#else
template<typename T, typename... Args>
void db(T &data, Args... args){}
#endif

int qpow(int a, int b)
{
	int res = 1;
	while(b)
	{
		if(b&1)res = res*a;
		a = a*a;
		b /= 2;
	}
	return res;
}

int T[MAXN][2];

bool mk[MAXN];

int contg = 0;

vector<int> vect;

int res = 0;

void DFS(int nodo, int lvl)
{
	if(!mk[nodo])vect.push_back(lvl), db(nodo);
	else res++;

	if(T[nodo][0])
	{
		DFS(T[nodo][0], lvl-1);
	}
	if(T[nodo][1])
	{
		DFS(T[nodo][1], lvl-1);
	}
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int N, K;
    cin >> N >> K;

    string A, B;
    cin >> A >> B;

    int pe = -1;

    for(int i = 0 ; i < N ; i++)
    {
    	if(A[i] == B[i])pe++;
    	else break;
    }

    // db(pe);

    int pt = 0;
    mk[pt] = true;

    for(int i = 0 ; i < N ; i++)
    {
    	if(A[i] == 'a')
    	{
    		if(T[pt][0] == 0)T[pt][0] = ++contg;
    		if(i > pe && T[pt][1] == 0)T[pt][1] = ++contg;

    		pt = T[pt][0];
    		mk[pt] = true;
    	}
    	else
    	{
    		if(T[pt][1] == 0)T[pt][1] = ++contg;

    		pt = T[pt][1];
    		mk[pt] = true;
    	}
    }

    pt = 0;

    for(int i = 0 ; i < N ; i++)
    {
    	if(B[i] == 'a')
    	{
    		if(T[pt][0] == 0)T[pt][0] = ++contg;

    		pt = T[pt][0];
    		mk[pt] = true;
    	}
    	else
    	{
    		if(i > pe && T[pt][0] == 0)T[pt][0] = ++contg;
    		if(T[pt][1] == 0)T[pt][1] = ++contg;

    		pt = T[pt][1];
    		mk[pt] = true;
    	}
    }

    DFS(0,N);

    // vect.push_back(0);
    // vect.push_back(0);

    db(vect);
    res--;

    // if(A == B)
    // {
    // 	cout << res << '\n';
    // 	return 0;
    // }
    // db(res);

    sort(vect.begin(), vect.end());
    reverse(vect.begin(), vect.end());

    for(int i = 0 ; i < vect.size() ; i++)
    {
    	vect[i]++;
    }

    vector<int> vvv(vect.size());

    priority_queue<pair<int,int>> Q;

    for(int i = 0 ; i < vvv.size() ; i++)
    {
		Q.push({vect[i], i});
    }

    // db(Q);

    if(K == 1)
    {
    	cout << N << '\n';
    	return 0;
    }

    if(K == 2)
    {
    	cout << res << '\n';
    	return 0;
    }

    K-=2;

    db(res);
    db(Q);

    while(Q.size())
    {
    	pair<int,int> pp = Q.top();
    	Q.pop();

    	db(111);

    	int tam = 0;

    	if(vvv[pp.second] == 0)tam = 1;
    	else tam = qpow(2,vvv[pp.second]-1);

    	if(tam < K)
    	{
    		K -= tam;
    		if(vvv[pp.second] == 0)res += vect[pp.second];
    		else res += (vect[pp.second] - vvv[pp.second]) * qpow(2,vvv[pp.second]-1);
    		vvv[pp.second]++;
    		if(vvv[pp.second] != vect[pp.second])Q.push({(vect[pp.second] - vvv[pp.second]), pp.second});
    	}
    	else
    	{
    		if(vvv[pp.second] == 0)res += vect[pp.second];
    		else res += (vect[pp.second] - vvv[pp.second]) * (K);
    		break;
    	}
    	// db(Q);
    }

    cout << res << '\n';
    return 0;
}


#include <bits/stdc++.h>

#define int long long

using namespace std;

const int MAXN = 5e6 + 100;

#ifdef LOCAL
#include "/media/brayand/BrayanD/debugger.h"
#else
template<typename T, typename... Args>
void db(T &data, Args... args){}
#endif

int qpow(int a, int b)
{
	int res = 1;
	while(b)
	{
		if(b&1)res = res*a;
		a = a*a;
		b /= 2;
	}
	return res;
}

int T[MAXN][2];

bool mk[MAXN];

int contg = 0;

vector<int> vect;

int res = 0;

void DFS(int nodo, int lvl)
{
	if(!mk[nodo])vect.push_back(lvl), db(nodo);
	else res++;

	if(T[nodo][0])
	{
		DFS(T[nodo][0], lvl-1);
	}
	if(T[nodo][1])
	{
		DFS(T[nodo][1], lvl-1);
	}
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int N, K;
    cin >> N >> K;

    string A, B;
    cin >> A >> B;

    int pe = -1;

    for(int i = 0 ; i < N ; i++)
    {
    	if(A[i] == B[i])pe++;
    	else break;
    }

    db(pe);

    int pt = 0;
    mk[pt] = true;

    for(int i = 0 ; i < N ; i++)
    {
    	if(A[i] == 'a')
    	{
    		if(T[pt][0] == 0)T[pt][0] = ++contg;
    		if(i >= pe && T[pt][1] == 0)T[pt][1] = ++contg;

    		pt = T[pt][0];
    		mk[pt] = true;
    	}
    	else
    	{
    		if(T[pt][1] == 0)T[pt][1] = ++contg;

    		pt = T[pt][1];
    		mk[pt] = true;
    	}
    }

    pt = 0;

    for(int i = 0 ; i < N ; i++)
    {
    	if(B[i] == 'a')
    	{
    		if(T[pt][0] == 0)T[pt][0] = ++contg;

    		pt = T[pt][0];
    		mk[pt] = true;
    	}
    	else
    	{
    		if(i >= pe && T[pt][0] == 0)T[pt][0] = ++contg;
    		if(T[pt][1] == 0)T[pt][1] = ++contg;

    		pt = T[pt][1];
    		mk[pt] = true;
    	}
    }

    DFS(0,N);

    // vect.push_back(0);
    // vect.push_back(0);

    db(vect);
    res--;
    db(res);

    sort(vect.begin(), vect.end());
    reverse(vect.begin(), vect.end());

    for(int i = 0 ; i < vect.size() ; i++)
    {
    	vect[i]++;
    }

    vector<int> vvv(vect.size());

    priority_queue<pair<int,int>> Q;

    for(int i = 0 ; i < vvv.size() ; i++)
    {
		Q.push({vect[i], i});
    }

    db(Q);

    if(K == 1)
    {
    	cout << N << '\n';
    	return 0;
    }

    if(K == 2)
    {
    	cout << res << '\n';
    	return 0;
    }

    K-=2;

    while(Q.size())
    {
    	pair<int,int> pp = Q.top();
    	Q.pop();

    	int tam = 0;

    	if(vvv[pp.second] == 0)tam = 1;
    	else tam = qpow(2,vvv[pp.second]-1);

    	if(tam < K)
    	{
    		K -= tam;
    		if(vvv[pp.second] == 0)res += vect[pp.second];
    		else res += (vect[pp.second] - vvv[pp.second]) * qpow(2,vvv[pp.second]-1);
    		vvv[pp.second]++;
    		if(vvv[pp.second] != vect[pp.second])Q.push({(vect[pp.second] - vvv[pp.second]), pp.second});
    	}
    	else
    	{
    		if(vvv[pp.second] == 0)res += vect[pp.second];
    		else res += (vect[pp.second] - vvv[pp.second]) * (K);
    		break;
    	}
    	db(Q);
    }

    cout << res << '\n';
    return 0;
}


#include <algorithm>
#include <array>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <numeric>
#include <string>
#include <type_traits>
#include <unistd.h>
#include <utility>
#include <vector>

using namespace std;

int main() {
    std::ios_base::sync_with_stdio(false);
    uint32_t n, k;
    string s, t;
    cin >> n >> k >> s >> t;

    uint64_t c = n;
    uint64_t used_strings = 1;
    uint64_t base_strings = 1;
    for (size_t i = 0; i < n && used_strings < k; ++i) {
        auto old_base_strings = base_strings;
        base_strings *= 2;
        if (s[i] == 'b') {
            base_strings--;
        }
        if (t[i] == 'a') {
            base_strings--;
        }

        auto new_strings = min(k - used_strings, base_strings - old_base_strings);
        c += new_strings * (n - i);

        used_strings += new_strings;
    }

//    size_t i = 1;
//    while (used_strings < k && prefix_len + i < n) {
//        base_strings *= 2;
//        if (s[prefix_len + i] == 'b') {
//            base_strings--;
//        }
//        if (t[prefix_len + i] == 'a') {
//            base_strings--;
//        }
//
//        base_strings = min(base_strings, k - used_strings);
//        c += static_cast<uint64_t>(base_strings) * (l - i);
//        used_strings += base_strings;
//        base_strings = max(base_strings, 1u);
//        ++i;
//    }

    cout << c << '\n';

    return 0;
}


#include <algorithm>
#include <array>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <numeric>
#include <string>
#include <type_traits>
#include <unistd.h>
#include <utility>
#include <vector>

using namespace std;

int main() {
    std::ios_base::sync_with_stdio(false);
    uint32_t n, k;
    string s, t;
    cin >> n >> k >> s >> t;

    size_t prefix_len = 0;
    while (s[prefix_len] == t[prefix_len]) {
        prefix_len++;
    }

    size_t l = n - prefix_len;
    uint64_t c = prefix_len + min(k, 2u) * l;

    uint32_t used_strings = 2;
    uint32_t base_strings = 1;
    size_t i = 1;
    while (used_strings < k && prefix_len + i < n) {
        base_strings *= 2;
        if (s[prefix_len + i] == 'b') {
            base_strings--;
        }
        if (t[prefix_len + i] == 'a') {
            base_strings--;
        }

        base_strings = min(base_strings, k - used_strings);
        c += static_cast<uint64_t>(base_strings) * (l - i);
        used_strings += base_strings;
        base_strings = max(base_strings, 1u);
        ++i;
    }

    cout << c << '\n';

    return 0;
}


#include <algorithm>
#include <array>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <numeric>
#include <string>
#include <type_traits>
#include <unistd.h>
#include <utility>
#include <vector>

using namespace std;

int main() {
    std::ios_base::sync_with_stdio(false);
    uint32_t n, k;
    string s, t;
    cin >> n >> k >> s >> t;

    uint64_t c = n;
    uint64_t used_strings = 0;
    uint64_t base_strings = 1;
    for (size_t i = 0; i < n && used_strings < k; ++i) {
        auto old_base_strings = base_strings;
        base_strings *= 2;
        if (s[i] == 'b') {
            base_strings--;
        }
        if (t[i] == 'a') {
            base_strings--;
        }

        auto new_strings = min(k - used_strings, base_strings - old_base_strings);
        c += new_strings * (n - i);

        used_strings += new_strings;
    }

//    size_t i = 1;
//    while (used_strings < k && prefix_len + i < n) {
//        base_strings *= 2;
//        if (s[prefix_len + i] == 'b') {
//            base_strings--;
//        }
//        if (t[prefix_len + i] == 'a') {
//            base_strings--;
//        }
//
//        base_strings = min(base_strings, k - used_strings);
//        c += static_cast<uint64_t>(base_strings) * (l - i);
//        used_strings += base_strings;
//        base_strings = max(base_strings, 1u);
//        ++i;
//    }

    cout << c << '\n';

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=5e5+10;
char a[N],b[N];
ll ans,n,k,temp=1;
int main() {
    cin>>n>>k>>a+1>>b+1;
    for(int i=1;i<=n;i++) {
        temp<<=1;
        if(b[i]=='a') temp--;
        if(a[i]=='b') temp--;
        temp=min(temp,k);
        ans+=temp;
    }
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=5e5+10;
char a[N],b[N];
ll ans,n,k,temp=1;
int main() {
    cin>>n>>k>>a+1>>b+1;
    for(int i=1;i<=n;i++) {
        temp<<=1;
        if(b[i]=='a') temp--;
        if(a[i]=='b') temp--;
        temp=min(temp,k+100);
        ans+=min(temp,k);
    }
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=5e5+10;
char a[N],b[N];
ll ans,n,k,temp=1;
int main() {
    cin>>n>>k>>a+1>>b+1;
    for(int i=1;i<=n;i++) {
        temp<<=1;
        if(b[i]=='a') temp--;
        if(a[i]=='b') temp--;
        temp=min(temp,k+1);
        ans+=min(temp,k);
    }
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=5e5+10;
char a[N],b[N];
ll ans,n,k,temp=1;
int main() {
    cin>>n>>k>>a+1>>b+1;
    for(int i=1;i<=n;i++) {
        temp<<=1;
        if(b[i]=='a') temp--;
        if(a[i]=='b') temp--;
        temp=min(temp,k);
        ans+=min(temp,k);
    }
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=5e5+10;
char a[N],b[N];
ll ans,n,k,temp=1;
int main() {
    cin>>n>>k>>a+1>>b+1;
    for(int i=1;i<=n;i++) {
        temp<<=1;
        if(b[i]=='a') temp--;
        if(a[i]=='b') temp--;
        if(temp>k) temp=k+1;
        ans+=min(temp,k);
    }
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=5e5+10;
char a[N],b[N];
ll ans,n,k,temp=1;
int main() {
    cin>>n>>k>>a+1>>b+1;
    for(int i=1;i<=n;i++) {
        temp<<=1;
        if(b[i]=='a') temp--;
        if(a[i]=='b') temp--;
        ans+=min(k,temp);
    }
    cout<<ans;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#define LL long long
#define maxn 500021
using namespace std;
LL n, k, a[maxn], b[maxn],cnt;
char s1[maxn], s2[maxn];

int main(){
	scanf("%I64d%I64d", &n, &k);
	scanf("%s%s", s1, s2);
	int i = 0;
	LL ans = 0;
	for(; i < n; i++){
		if(s1[i] != s2[i])break;
		ans++;
	}
	for(; i < n; i++){
		a[++cnt] = s1[i] == 'b';
		b[cnt] = s2[i] == 'b';
	}
	LL h = cnt, now = 1, hv = 0, last;

	for(i = 1; i <= cnt; i++){
		now *= 2ll;
		if(a[i] == 1)now--;
		if(b[i] == 0)now--;
		last = now - hv;
		ans += last * h;
		hv += last;
		if(hv == k)break;
		h--;
	}

	printf("%I64d", ans);
	return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#define LL long long
#define maxn 500021
using namespace std;
LL n, k, a[maxn], b[maxn],cnt;
char s1[maxn], s2[maxn];

int main(){
	scanf("%I64d%I64d", &n, &k);
	scanf("%s%s", s1, s2);
	int i = 0;
	LL ans = 0;
	for(; i < n; i++){
		if(s1[i] != s2[i])break;
		ans++;
	}
	for(; i < n; i++){
		a[++cnt] = s1[i] == 'b';
		b[cnt] = s2[i] == 'b';
	}
	LL h = cnt, now = 1, hv = 0, last;

	for(i = 1; i <= cnt; i++){
		now *= 2ll;
		if(a[i] == 1)now--;
		if(b[i] == 0)now--;
		last = now - hv;
		if(last + hv >= k){
			ans += (k - hv) * h;
			break;
		}
		ans += last * h;
		hv += last;
		h--;
	}

	printf("%I64d", ans);
	return 0;
}


 //
#include<bits/stdc++.h>

using namespace std;

#define PB push_back
#define f first
#define s second
#define what_is(x) cderr << #x << " is " << x << endl;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int MAXN = 500005;
ll dp[MAXN], n, k;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> k;
    string s, t;
    cin >> s >> t;
    dp[0] = 1;
    ll ans = 0;
    for(int i=1; i<=n; i++)
    {
        dp[i] = dp[i-1] * 2;
        if(s[i-1] == 'b')
            dp[i]--;
        if(t[i-1] == 'a')
            dp[i]--;
        dp[i] = min(dp[i], k);
        ans += dp[i];
    }
    cout << ans;

    return 0;
}


 //
#include<bits/stdc++.h>

using namespace std;

#define PB push_back
#define f first
#define s second
#define what_is(x) cderr << #x << " is " << x << endl;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int MAXN = 500005;
ll dp[MAXN], n, k;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> k;
    string s, t;
    cin >> s >> t;
    dp[0] = 1;
    ll ans = 0;
    for(int i=1; i<=n; i++)
    {
        dp[i] = dp[i-1] * 2;
        if(s[i-1] == 'b')
            dp[i]--;
        if(t[i-1] == 'a')
            dp[i]--;
        dp[i] = min(dp[i], 1LL * 1000000007);
        ans += min(dp[i], k);
    }
    cout << ans;

    return 0;
}


#include <iostream>
#include <string>

using namespace std;

const long long P = 1000000007;

int main()
{
	string s;
	cin >> s;
	long long cnt = 0, ans = 1;
	for (char c : s)
	{
		if (c == 'a')
		{
			cnt++;
		}
		else if (c == 'b')
		{
			ans *= (cnt + 1);
			ans %= P;
			cnt = 0;
		}
	}
	ans *= (cnt + 1);
	ans %= P;
	cout << ans - 1;
	//system("pause");
}


#include <bits/stdc++.h>

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	int n, k;
	cin >> n >> k;
	string s, t;
	cin >> s >> t;
	long long ans = 0;
	int diff = 0;
	for (int i = 0; i < n; ++i) {
		if (diff < k) {
			diff *= 2;
			diff += t[i] - s[i];
		}
		ans += min(diff + 1, k);
	}
	cout << ans;

	return 0;
}


#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>		//UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>		//do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)
#define ALL(u) (u).begin(),(u).end()

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

typedef pair<int, int> PII;

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;

const int MR = 5e5 + 10;

char s[MR], t[MR];

int main()
{
	int n, k;
	scanf("%d%d%s%s", &n, &k, s, t);

	LL res = 0;

	int ile = 1;

	REP(i, n)
	{
		if (s[i] == t[i])
			ile = 2 * ile - 1;
		else if (s[i] < t[i])
			ile = 2 * ile;
		else
			ile = 2 * ile - 2;

		ile = min(ile, k);

		res += ile;
	}

	printf("%lld\n", res);

	return 0;
}


#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>		//UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>		//do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)
#define ALL(u) (u).begin(),(u).end()

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

typedef pair<int, int> PII;

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;

const int MR = 5e5 + 10;

char s[MR], t[MR];

int main()
{
	int n, k;
	scanf("%d%d%s%s", &n, &k, s, t);

	LL res = 0;

	int ile = 1;

	REP(i, n)
	{
		if (s[i] == t[i])
			ile = 2 * ile - 1;
		else if (s[i] < t[i])
			ile = 2 * ile;
		else
			ile = 2 * ile - 2;

		ile = min(max(ile, 1), k);

		res += ile;
	}

	printf("%lld\n", res);

	return 0;
}


#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>		//UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>		//do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)
#define ALL(u) (u).begin(),(u).end()

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

typedef pair<int, int> PII;

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;

const int MR = 5e5 + 10;

char s[MR], t[MR];

string sub(string s, string t)
{
	// odejmujemy stringi postaci aaba, a dostajemy string z 0 i 1
	string res = "";
	bool p = 0;
	FORD(i, s.length(), 0)
		if (t[i] - p >= s[i])
		{
			res += t[i] - p - s[i] + '0';
			p = 0;
		}
		else
		{
			res += t[i] - p - s[i] + 2 + '0';
			p = 1;
		}

	while (!res.empty() && res.back() == '0')
		res.pop_back();

	reverse(res.begin(), res.end());

	return res;
}

int main()
{
	int n, k;
	scanf("%d%d%s%s", &n, &k, s, t);

	int pref = 0;
	while (pref < n && s[pref] == t[pref])
		pref++;

	if (pref == n)
	{
		printf("%d\n", n);
		return 0;
	}

	LL res = pref;

	string suf = sub(string(s + pref), string(t + pref));

	LL ile = 0;
	int dl = n - suf.length() + 1;
	REP(i, suf.length())
	{
		ile = (ile * 2 + suf[i] - '0');
		ile = min(ile, (LL)k);
		res += min(ile + 1, (LL)k);
	}

	printf("%lld\n", res*dl);

	return 0;
}


#include<bits/stdc++.h>
using namespace std;

const long long mod = 1e9+7;
const int N = 5e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fr(l,m) for(int i=l;i<m;i++)

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll pwr(ll x,ll y);
bool isprime(ll x);

ll a[N],b[N],c[N];
bool x[N],y[N];

ll bs(int x,int y,int k)
{
    int l=x,r=y;
    while(l<r)
    {
       // cout<<l<<' '<<r<<endl;
        int mid=(l+(r-l)/2);
        if(a[mid]<k)
        {
            l=mid+1;
        }
        else
        {
            r=mid;
        }
    }
    if(l>y){return y;}
    if(a[l]>k){if(l==x)return -1;else return l-1;}
    return l;
}

int main()
{
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

// Code Here
ll n,k,temp=0;
cin>>n>>k;
string s,t;
cin>>s>>t;
fr(0,n)
{
    if(s[i]=='b'){x[i]=1;}
    if(t[i]=='b'){y[i]=1;}
    c[i]=(temp*2+y[i]-x[i]);
    temp=c[i];
}
if(n==k){cout<<n<<endl;return 0 ;}
fr(0,n)
{
   a[i] =(c[i]+1);
   if(i==0){b[i]=a[i]; continue;}
   b[i]=(b[i-1]+a[i]);

}
    ll p=bs(0,n-1,k);

   ll sum=0;
if(p==-1)
{
    sum=k*(n);
}
else
{
    sum+=b[p];
    sum+=k*(n-p-1);
}
cout<<sum<<endl;
return 0;
}

/////////
/////////
/////////
ll pwr(ll x,ll y)
{
    ll ans=1;
    x=x%mod;
    while(y>0){
    if(y&1)ans=(x*ans)%mod;
    x=(x*x)%mod;
    y=y/2;
    }
    return ans;
}
bool isprime(ll x)
{
    if(x<2)return false;
    if(x<4)return true;
    if(x%2==0 || x%3==0)return false;
    for(ll i=5;i*i<=x;i+=6)
    {
        if(x%i==0 ||x%(i+2)==0)return false;
    }
    return true;
}


#include<bits/stdc++.h>
using namespace std;

const long long mod = 1e9+7;
const int N = 5e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fr(l,m) for(int i=l;i<m;i++)

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll pwr(ll x,ll y);
bool isprime(ll x);

ll a[N],b[N];
bool x[N],y[N];

ll g(ll m)
{
    ll l=0,r=0;
    for(int i=m;i>=0;i--)
    {
        l+=pow(2,m-i)*x[i];
        r+=pow(2,m-i)*y[i];

    }
   // cout<<l<<" "<<r<<endl;
    return (r-l+1);
}
int bs(int l,int r,int k)
{
    while(l<r)
    {
        int mid=(l+(r-l)/2);
        if(a[mid]<=k)
        {
            l=mid;
        }
        else if(a[mid]>k)
        {
            r=mid-1;
        }
    }
    if(a[l]<=k){return l;}
    else return -1;
}

int main()
{
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

// Code Here
int n,k;
cin>>n>>k;
string s,t;
cin>>s>>t;
fr(0,n)
{
    if(s[i]=='b'){x[i]=1;}
    if(t[i]=='b'){y[i]=1;}
}
fr(0,n)
{
   a[i] = g(i);
   if(i==0){b[i]=a[i];continue;}
   b[i]=(b[i-1]+a[i]);
}

    int p=bs(0,n,k);
   ll sum=0;
if(p==-1)
{
    sum=k*(n);
}
else
{
    sum+=b[p];
    sum+=k*(n-p-1);
}
cout<<sum<<endl;
return 0;
}

/////////
/////////
/////////
ll pwr(ll x,ll y)
{
    ll ans=1;
    x=x%mod;
    while(y>0){
    if(y&1)ans=(x*ans)%mod;
    x=(x*x)%mod;
    y=y/2;
    }
    return ans;
}
bool isprime(ll x)
{
    if(x<2)return false;
    if(x<4)return true;
    if(x%2==0 || x%3==0)return false;
    for(ll i=5;i*i<=x;i+=6)
    {
        if(x%i==0 ||x%(i+2)==0)return false;
    }
    return true;
}


#include<bits/stdc++.h>
using namespace std;

const long long mod = 1e9+7;
const int N = 5e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fr(l,m) for(int i=l;i<m;i++)

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll pwr(ll x,ll y);
bool isprime(ll x);

ll a[N],b[N];
bool x[N],y[N];

ll g(ll m)
{
    ll l=0,r=0;
    for(int i=m;i>=0;i--)
    {
        l+=pow(2,m-i)*x[i];
        r+=pow(2,m-i)*y[i];

    }
   // cout<<l<<" "<<r<<endl;
    return (r-l+1);
}
int bs(int l,int r,int k)
{
    while(l<r)
    {
       // cout<<l<<' '<<r<<endl;
        int mid=(l+(r-l)/2);
        if(a[mid]<k)
        {
            l=mid+1;
        }
        else
        {
            r=mid;
        }
    }
    if(a[l]<=k){return l;}
    else return -1;
}

int main()
{
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

// Code Here
int n,k;
cin>>n>>k;
string s,t;
cin>>s>>t;
fr(0,n)
{
    if(s[i]=='b'){x[i]=1;}
    if(t[i]=='b'){y[i]=1;}
}
fr(0,n)
{
   a[i] = g(i);
   if(i==0){b[i]=a[i];continue;}
   b[i]=(b[i-1]+a[i]);
}

    int p=bs(0,n-1,k);
   ll sum=0;
if(p==-1)
{
    sum=k*(n);
}
else
{
    sum+=b[p];
    sum+=k*(n-p-1);
}
cout<<sum<<endl;
return 0;
}

/////////
/////////
/////////
ll pwr(ll x,ll y)
{
    ll ans=1;
    x=x%mod;
    while(y>0){
    if(y&1)ans=(x*ans)%mod;
    x=(x*x)%mod;
    y=y/2;
    }
    return ans;
}
bool isprime(ll x)
{
    if(x<2)return false;
    if(x<4)return true;
    if(x%2==0 || x%3==0)return false;
    for(ll i=5;i*i<=x;i+=6)
    {
        if(x%i==0 ||x%(i+2)==0)return false;
    }
    return true;
}


#include<bits/stdc++.h>
using namespace std;

const long long mod = 1e9+7;
const int N = 5e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fr(l,m) for(int i=l;i<m;i++)

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll pwr(ll x,ll y);
bool isprime(ll x);

ll a[N],b[N],c[N];
bool x[N],y[N];

ll bs(int x,int y,int k)
{
    int l=x,r=y;
    while(l<r)
    {
       // cout<<l<<' '<<r<<endl;
        int mid=(l+(r-l)/2);
        if(a[mid]<k)
        {
            l=mid+1;
        }
        else
        {
            r=mid;
        }
    }
    if(l>y){return y;}
    if(a[l]>k){if(l==x)return -1;else return l-1;}
    return l;
}

int main()
{
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

// Code Here
ll n,k,temp=0;
cin>>n>>k;
string s,t;
cin>>s>>t;
fr(0,n)
{
    if(s[i]=='b'){x[i]=1;}
    if(t[i]=='b'){y[i]=1;}
    c[i]=(temp*2+y[i]-x[i]);
    temp=c[i];
}
if(k==1){cout<<n<<endl;return 0 ;}
fr(0,n)
{
   a[i] =(c[i]+1);
   if(i==0){b[i]=a[i]; continue;}
   b[i]=(b[i-1]+a[i]);

}
    ll p=bs(0,n-1,k);

   ll sum=0;
if(p==-1)
{
    sum=k*(n);
}
else
{
    sum+=b[p];
    sum+=k*(n-p-1);
}
cout<<sum<<endl;
return 0;
}

/////////
/////////
/////////
ll pwr(ll x,ll y)
{
    ll ans=1;
    x=x%mod;
    while(y>0){
    if(y&1)ans=(x*ans)%mod;
    x=(x*x)%mod;
    y=y/2;
    }
    return ans;
}
bool isprime(ll x)
{
    if(x<2)return false;
    if(x<4)return true;
    if(x%2==0 || x%3==0)return false;
    for(ll i=5;i*i<=x;i+=6)
    {
        if(x%i==0 ||x%(i+2)==0)return false;
    }
    return true;
}


#include<bits/stdc++.h>
using namespace std;

const long long mod = 1e9+7;
const int N = 5e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fr(l,m) for(int i=l;i<m;i++)

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll pwr(ll x,ll y);
bool isprime(ll x);

ll a[N],b[N];
bool x[N],y[N];

ll g(ll m)
{
    ll l=0,r=0;
    for(int i=m;i>=0;i--)
    {
        l+=pow(2,m-i)*x[i];
        r+=pow(2,m-i)*y[i];

    }
   // cout<<l<<" "<<r<<endl;
    return (r-l+1);
}
int bs(int x,int y,int k)
{
    int l=x,r=y;
    while(l<r)
    {
       // cout<<l<<' '<<r<<endl;
        int mid=(l+(r-l)/2);
        if(a[mid]<k)
        {
            l=mid+1;
        }
        else
        {
            r=mid;
        }
    }
    if(l>y){return y;}
    if(a[l]>k){if(l==x)return -1;else return l-1;}
    return l;
}

int main()
{
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

// Code Here
int n,k;
cin>>n>>k;
string s,t;
cin>>s>>t;
fr(0,n)
{
    if(s[i]=='b'){x[i]=1;}
    if(t[i]=='b'){y[i]=1;}
}
fr(0,n)
{
   a[i] = g(i);
   if(i==0){b[i]=a[i]; continue;}
   b[i]=(b[i-1]+a[i]);

}
    int p=bs(0,n-1,k);

   ll sum=0;
if(p==-1)
{
    sum=k*(n);
}
else
{
    sum+=b[p];
    sum+=k*(n-p-1);
}
cout<<sum<<endl;
return 0;
}

/////////
/////////
/////////
ll pwr(ll x,ll y)
{
    ll ans=1;
    x=x%mod;
    while(y>0){
    if(y&1)ans=(x*ans)%mod;
    x=(x*x)%mod;
    y=y/2;
    }
    return ans;
}
bool isprime(ll x)
{
    if(x<2)return false;
    if(x<4)return true;
    if(x%2==0 || x%3==0)return false;
    for(ll i=5;i*i<=x;i+=6)
    {
        if(x%i==0 ||x%(i+2)==0)return false;
    }
    return true;
}


#include<bits/stdc++.h>
using namespace std;

const long long mod = 1e9+7;
const int N = 5e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fr(l,m) for(int i=l;i<m;i++)

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll pwr(ll x,ll y);
bool isprime(ll x);

ll a[N],b[N],c[N];
bool x[N],y[N];

ll bs(int x,int y,int k)
{
    int l=x,r=y;
    while(l<r)
    {
       // cout<<l<<' '<<r<<endl;
        int mid=(l+(r-l)/2);
        if(a[mid]<k)
        {
            l=mid+1;
        }
        else
        {
            r=mid;
        }
    }
    if(l>y){return y;}
    if(a[l]>k){if(l==x)return -1;else return l-1;}
    return l;
}

int main()
{
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

// Code Here
ll n,k,temp=0;
cin>>n>>k;
string s,t;
cin>>s>>t;
fr(0,n)
{
    if(s[i]=='b'){x[i]=1;}
    if(t[i]=='b'){y[i]=1;}
    c[i]=(temp*2+y[i]-x[i]);
    temp=c[i]++;
}
if(k==1){cout<<n<<endl;return 0 ;}

ll sum=0;
temp=1;
fr(0,n)
{

    if(c[i]<=k){sum+=c[i];temp=c[i];}
    else
    {

        sum+=temp;

    }
}

/*
ll p=bs(0,n-1,k);
ll sum=0;
if(p==-1)
{
    sum=k*(n);
}
else
{
    sum+=b[p];
    sum+=k*(n-p-1);
}
*/

cout<<sum<<endl;
return 0;
}

/////////
/////////
/////////
ll pwr(ll x,ll y)
{
    ll ans=1;
    x=x%mod;
    while(y>0){
    if(y&1)ans=(x*ans)%mod;
    x=(x*x)%mod;
    y=y/2;
    }
    return ans;
}
bool isprime(ll x)
{
    if(x<2)return false;
    if(x<4)return true;
    if(x%2==0 || x%3==0)return false;
    for(ll i=5;i*i<=x;i+=6)
    {
        if(x%i==0 ||x%(i+2)==0)return false;
    }
    return true;
}


#include<bits/stdc++.h>
using namespace std;

const long long mod = 1e9+7;
const int N = 5e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fr(l,m) for(int i=l;i<m;i++)

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll pwr(ll x,ll y);
bool isprime(ll x);

ll a[N],b[N];
bool x[N],y[N];

ll g(ll m)
{
    ll l=0,r=0;
    for(int i=m;i>=0;i--)
    {
        l+=pow(2,m-i)*x[i];
        r+=pow(2,m-i)*y[i];

    }
   // cout<<l<<" "<<r<<endl;
    return (r-l+1);
}

int main()
{
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

// Code Here
int n,k;
cin>>n>>k;
string s,t;
cin>>s>>t;
fr(0,n)
{
    if(s[i]=='b'){x[i]=1;}
    if(t[i]=='b'){y[i]=1;}
}
fr(0,n)
{
   a[i] = g(i);

}

    int p=n-1;
while(a[p]>k)
{
    p--;
}

ll sum=a[p]*(n-p-1);

fr(0,p+1)
{
    sum+=a[i];

}
cout<<sum<<endl;
return 0;
}

/////////
/////////
/////////
ll pwr(ll x,ll y)
{
    ll ans=1;
    x=x%mod;
    while(y>0){
    if(y&1)ans=(x*ans)%mod;
    x=(x*x)%mod;
    y=y/2;
    }
    return ans;
}
bool isprime(ll x)
{
    if(x<2)return false;
    if(x<4)return true;
    if(x%2==0 || x%3==0)return false;
    for(ll i=5;i*i<=x;i+=6)
    {
        if(x%i==0 ||x%(i+2)==0)return false;
    }
    return true;
}


#include<bits/stdc++.h>
using namespace std;

const long long mod = 1e9+7;
const int N = 5e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fr(l,m) for(int i=l;i<m;i++)

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll pwr(ll x,ll y);
bool isprime(ll x);

ll a[N],b[N],c[N];
bool x[N],y[N];

int main()
{
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

// Code Here
ll n,k,temp=0;
cin>>n>>k;
string s,t;
cin>>s>>t;
fr(0,n)
{
    if(s[i]=='b'){x[i]=1;}
    if(t[i]=='b'){y[i]=1;}
    c[i]=(temp*2+y[i]-x[i]);
    if(c[i]>pow(10,9))
    {
        for(int j=i;j<n;j++){c[i]=pow(10,9);}
        break;
    }
    temp=c[i]++;
}
ll sum=0;
fr(0,n)
{
sum+=min(c[i],k);
}
cout<<sum<<endl;
return 0;
}

/////////
/////////
/////////
ll pwr(ll x,ll y)
{
    ll ans=1;
    x=x%mod;
    while(y>0){
    if(y&1)ans=(x*ans)%mod;
    x=(x*x)%mod;
    y=y/2;
    }
    return ans;
}
bool isprime(ll x)
{
    if(x<2)return false;
    if(x<4)return true;
    if(x%2==0 || x%3==0)return false;
    for(ll i=5;i*i<=x;i+=6)
    {
        if(x%i==0 ||x%(i+2)==0)return false;
    }
    return true;
}


#include<bits/stdc++.h>
using namespace std;

const long long mod = 1e9+7;
const int N = 5e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fr(l,m) for(int i=l;i<m;i++)

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll pwr(ll x,ll y);
bool isprime(ll x);

ll a[N],b[N],c[N];
bool x[N],y[N];

int main()
{
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

// Code Here

ll n,k,temp=0;
cin>>n>>k;
string s,t;
cin>>s>>t;
n=s.size();
fr(0,n)
{
    if(s[i]=='b'){x[i]=1;}
    if(t[i]=='b'){y[i]=1;}
    c[i]=(temp*2+y[i]-x[i]);
    if(c[i]>=1000000000ll)
    {
        for(int j=i;j<n;j++){c[j]=1000000000ll;}
        break;
    }
    temp=c[i]++;
}

ll sum=0;
fr(0,n)
{
sum+=min(c[i],k);

}

cout<<sum<<endl;
return 0;
}

/////////
/////////
/////////
ll pwr(ll x,ll y)
{
    ll ans=1;
    x=x%mod;
    while(y>0){
    if(y&1)ans=(x*ans)%mod;
    x=(x*x)%mod;
    y=y/2;
    }
    return ans;
}
bool isprime(ll x)
{
    if(x<2)return false;
    if(x<4)return true;
    if(x%2==0 || x%3==0)return false;
    for(ll i=5;i*i<=x;i+=6)
    {
        if(x%i==0 ||x%(i+2)==0)return false;
    }
    return true;
}


#include<bits/stdc++.h>
using namespace std;

const long long mod = 1e9+7;
const int N = 5e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fr(l,m) for(int i=l;i<m;i++)

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll pwr(ll x,ll y);
bool isprime(ll x);

ll a[N],b[N];
bool x[N],y[N];

ll g(ll m)
{
    ll l=0,r=0;
    for(int i=m;i>=0;i--)
    {
        l+=pow(2,m-i)*x[i];
        r+=pow(2,m-i)*y[i];

    }
   // cout<<l<<" "<<r<<endl;
    return (r-l+1);
}
int bs(int x,int y,int k)
{
    int l=x,r=y;
    while(l<r)
    {
       // cout<<l<<' '<<r<<endl;
        int mid=(l+(r-l)/2);
        if(a[mid]<k)
        {
            l=mid+1;
        }
        else
        {
            r=mid;
        }
    }
    if(l>y){return y;}
    if(a[l]>k)return -1;
    return l;
}

int main()
{
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

// Code Here
int n,k;
cin>>n>>k;
string s,t;
cin>>s>>t;
fr(0,n)
{
    if(s[i]=='b'){x[i]=1;}
    if(t[i]=='b'){y[i]=1;}
}
fr(0,n)
{
   a[i] = g(i);
   if(i==0){b[i]=a[i];continue;}
   b[i]=(b[i-1]+a[i]);
}

    int p=bs(0,n-1,k);
   ll sum=0;
if(p==-1)
{
    sum=k*(n);
}
else
{
    sum+=b[p];
    sum+=k*(n-p-1);
}
cout<<sum<<endl;
return 0;
}

/////////
/////////
/////////
ll pwr(ll x,ll y)
{
    ll ans=1;
    x=x%mod;
    while(y>0){
    if(y&1)ans=(x*ans)%mod;
    x=(x*x)%mod;
    y=y/2;
    }
    return ans;
}
bool isprime(ll x)
{
    if(x<2)return false;
    if(x<4)return true;
    if(x%2==0 || x%3==0)return false;
    for(ll i=5;i*i<=x;i+=6)
    {
        if(x%i==0 ||x%(i+2)==0)return false;
    }
    return true;
}


#include<bits/stdc++.h>
using namespace std;

const long long mod = 1e9+7;
const int N = 5e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fr(l,m) for(int i=l;i<m;i++)

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll pwr(ll x,ll y);
bool isprime(ll x);

ll a[N],b[N];
bool x[N],y[N];

ll g(ll m)
{
    ll l=0,r=0;
    for(int i=m;i>=0;i--)
    {
        l+=pow(2,m-i)*x[i];
        r+=pow(2,m-i)*y[i];

    }
   // cout<<l<<" "<<r<<endl;
    return (r-l+1);
}
int bs(int x,int y,int k)
{
    int l=x,r=y;
    while(l<r)
    {
       // cout<<l<<' '<<r<<endl;
        int mid=(l+(r-l)/2);
        if(a[mid]<k)
        {
            l=mid+1;
        }
        else
        {
            r=mid;
        }
    }
    if(l>y){return y;}
    if(a[l]>k){if(l==x)return -1;else return l-1;}
    return l;
}

int main()
{
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

// Code Here
int n,k;
cin>>n>>k;
string s,t;
cin>>s>>t;
fr(0,n)
{
    if(s[i]=='b'){x[i]=1;}
    if(t[i]=='b'){y[i]=1;}
}
fr(0,n)
{
   a[i] = g(i);
   if(i==0){b[i]=a[i]; cout<<b[i]<<' ';continue;}
   b[i]=(b[i-1]+a[i]);
   cout<<b[i]<<' ';
}
cout<<endl;
    int p=bs(0,n-1,k);
    cout<<p<<endl;
   ll sum=0;
if(p==-1)
{
    sum=k*(n);
}
else
{
    sum+=b[p];
    sum+=k*(n-p-1);
}
cout<<sum<<endl;
return 0;
}

/////////
/////////
/////////
ll pwr(ll x,ll y)
{
    ll ans=1;
    x=x%mod;
    while(y>0){
    if(y&1)ans=(x*ans)%mod;
    x=(x*x)%mod;
    y=y/2;
    }
    return ans;
}
bool isprime(ll x)
{
    if(x<2)return false;
    if(x<4)return true;
    if(x%2==0 || x%3==0)return false;
    for(ll i=5;i*i<=x;i+=6)
    {
        if(x%i==0 ||x%(i+2)==0)return false;
    }
    return true;
}


#include<bits/stdc++.h>
using namespace std;

const long long mod = 1e9+7;
const int N = 5e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fr(l,m) for(int i=l;i<m;i++)

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll pwr(ll x,ll y);
bool isprime(ll x);

ll a[N],b[N];
bool x[N],y[N];

ll g(ll m)
{
    ll l=0,r=0;
    for(int i=m;i>=0;i--)
    {
        l+=pow(2,m-i)*x[i];
        r+=pow(2,m-i)*y[i];

    }
   // cout<<l<<" "<<r<<endl;
    return (r-l+1);
}

int main()
{
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

// Code Here
int n,k;
cin>>n>>k;
string s,t;
cin>>s>>t;
fr(0,n)
{
    if(s[i]=='b'){x[i]=1;}
    if(t[i]=='b'){y[i]=1;}
}
fr(0,n)
{
   a[i] = g(i);

}

    int p=n-1;
while(a[p]>k)
{
    p--;
    if(p<0){break;}
}

ll sum=k*(n-p-1);

fr(0,p+1)
{
    sum+=a[i];

}
cout<<sum<<endl;
return 0;
}

/////////
/////////
/////////
ll pwr(ll x,ll y)
{
    ll ans=1;
    x=x%mod;
    while(y>0){
    if(y&1)ans=(x*ans)%mod;
    x=(x*x)%mod;
    y=y/2;
    }
    return ans;
}
bool isprime(ll x)
{
    if(x<2)return false;
    if(x<4)return true;
    if(x%2==0 || x%3==0)return false;
    for(ll i=5;i*i<=x;i+=6)
    {
        if(x%i==0 ||x%(i+2)==0)return false;
    }
    return true;
}


#include<bits/stdc++.h>
using namespace std;

const long long mod = 1e9+7;
const int N = 5e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fr(l,m) for(int i=l;i<m;i++)

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll pwr(ll x,ll y);
bool isprime(ll x);

ll a[N],b[N],c[N];
bool x[N],y[N];

ll bs(int x,int y,int k)
{
    int l=x,r=y;
    while(l<r)
    {
       // cout<<l<<' '<<r<<endl;
        int mid=(l+(r-l)/2);
        if(a[mid]<k)
        {
            l=mid+1;
        }
        else
        {
            r=mid;
        }
    }
    if(l>y){return y;}
    if(a[l]>k){if(l==x)return -1;else return l-1;}
    return l;
}

int main()
{
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

// Code Here
ll n,k,temp=0;
cin>>n>>k;
string s,t;
cin>>s>>t;
fr(0,n)
{
    if(s[i]=='b'){x[i]=1;}
    if(t[i]=='b'){y[i]=1;}
    c[i]=(temp*2+y[i]-x[i]);
    temp=c[i]++;
}
if(k==1){cout<<n<<endl;return 0 ;}

ll sum=0;
temp=1;
fr(0,n)
{

    if(c[i]<=k){sum+=c[i];temp=c[i];}
    else
    {

        sum+=min(c[i],k);

    }
}

/*
ll p=bs(0,n-1,k);
ll sum=0;
if(p==-1)
{
    sum=k*(n);
}
else
{
    sum+=b[p];
    sum+=k*(n-p-1);
}
*/

cout<<sum<<endl;
return 0;
}

/////////
/////////
/////////
ll pwr(ll x,ll y)
{
    ll ans=1;
    x=x%mod;
    while(y>0){
    if(y&1)ans=(x*ans)%mod;
    x=(x*x)%mod;
    y=y/2;
    }
    return ans;
}
bool isprime(ll x)
{
    if(x<2)return false;
    if(x<4)return true;
    if(x%2==0 || x%3==0)return false;
    for(ll i=5;i*i<=x;i+=6)
    {
        if(x%i==0 ||x%(i+2)==0)return false;
    }
    return true;
}


#include<bits/stdc++.h>
using namespace std;

const long long mod = 1e9+7;
const int N = 5e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fr(l,m) for(int i=l;i<m;i++)

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll pwr(ll x,ll y);
bool isprime(ll x);

ll a[N],b[N],c[N];
bool x[N],y[N];

int main()
{
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

// Code Here
ll n,k,temp=0;
cin>>n>>k;
string s,t;
cin>>s>>t;
fr(0,n)
{
    if(s[i]=='b'){x[i]=1;}
    if(t[i]=='b'){y[i]=1;}
    c[i]=(temp*2+y[i]-x[i]);
    if(c[i]>pow(10,9))
    {
        for(int j=i;j<n;j++){c[i]=pow(10,9);}
        break;
    }
    temp=c[i]++;
}
if(k==1){cout<<n<<endl;return 0 ;}

ll sum=0;
fr(0,n)
{

    if(c[i]<=k){sum+=c[i];}
    else
    {

        sum+=min(c[i],k);

    }
}
cout<<sum<<endl;
return 0;
}

/////////
/////////
/////////
ll pwr(ll x,ll y)
{
    ll ans=1;
    x=x%mod;
    while(y>0){
    if(y&1)ans=(x*ans)%mod;
    x=(x*x)%mod;
    y=y/2;
    }
    return ans;
}
bool isprime(ll x)
{
    if(x<2)return false;
    if(x<4)return true;
    if(x%2==0 || x%3==0)return false;
    for(ll i=5;i*i<=x;i+=6)
    {
        if(x%i==0 ||x%(i+2)==0)return false;
    }
    return true;
}


#include<bits/stdc++.h>
using namespace std;

const long long mod = 1e9+7;
const int N = 5e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fr(l,m) for(int i=l;i<m;i++)

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll pwr(ll x,ll y);
bool isprime(ll x);

ll a[N],b[N],c[N];
bool x[N],y[N];

ll bs(int x,int y,int k)
{
    int l=x,r=y;
    while(l<r)
    {
       // cout<<l<<' '<<r<<endl;
        int mid=(l+(r-l)/2);
        if(a[mid]<k)
        {
            l=mid+1;
        }
        else
        {
            r=mid;
        }
    }
    if(l>y){return y;}
    if(a[l]>k){if(l==x)return -1;else return l-1;}
    return l;
}

int main()
{
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

// Code Here
ll n,k,temp=0;
cin>>n>>k;
string s,t;
cin>>s>>t;
fr(0,n)
{
    if(s[i]=='b'){x[i]=1;}
    if(t[i]=='b'){y[i]=1;}
    c[i]=(temp*2+y[i]-x[i]);
    temp=c[i]++;
}
if(k==1){cout<<n<<endl;return 0 ;}

ll sum=0;
fr(0,n)
{
    if(c[i]<=k){sum+=c[i];temp=c[i];}
    else
    {
        if(i==0)
        {
            cout<<(k*(n))<<endl;
            return 0;
        }
        sum+=temp;

    }
}

/*
ll p=bs(0,n-1,k);
ll sum=0;
if(p==-1)
{
    sum=k*(n);
}
else
{
    sum+=b[p];
    sum+=k*(n-p-1);
}
*/

cout<<sum<<endl;
return 0;
}

/////////
/////////
/////////
ll pwr(ll x,ll y)
{
    ll ans=1;
    x=x%mod;
    while(y>0){
    if(y&1)ans=(x*ans)%mod;
    x=(x*x)%mod;
    y=y/2;
    }
    return ans;
}
bool isprime(ll x)
{
    if(x<2)return false;
    if(x<4)return true;
    if(x%2==0 || x%3==0)return false;
    for(ll i=5;i*i<=x;i+=6)
    {
        if(x%i==0 ||x%(i+2)==0)return false;
    }
    return true;
}


#include<bits/stdc++.h>
using namespace std;

const long long mod = 1e9+7;
const int N = 5e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fr(l,m) for(int i=l;i<m;i++)

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll pwr(ll x,ll y);
bool isprime(ll x);

ll a[N],b[N];
bool x[N],y[N];

ll g(ll m)
{
    ll l=0,r=0;
    for(int i=m;i>=0;i--)
    {
        l+=pow(2,m-i)*x[i];
        r+=pow(2,m-i)*y[i];

    }
   // cout<<l<<" "<<r<<endl;
    return (r-l+1);
}

int main()
{
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

// Code Here
int n,k;
cin>>n>>k;
string s,t;
cin>>s>>t;
fr(0,n)
{
    if(s[i]=='b'){x[i]=1;}
    if(t[i]=='b'){y[i]=1;}
}
fr(0,n)
{
   a[i] = g(i);

}

    int p=n-1;
while(a[p]>k)
{
    p--;
}

ll sum=k*(n-p-1);

fr(0,p+1)
{
    sum+=a[i];

}
cout<<sum<<endl;
return 0;
}

/////////
/////////
/////////
ll pwr(ll x,ll y)
{
    ll ans=1;
    x=x%mod;
    while(y>0){
    if(y&1)ans=(x*ans)%mod;
    x=(x*x)%mod;
    y=y/2;
    }
    return ans;
}
bool isprime(ll x)
{
    if(x<2)return false;
    if(x<4)return true;
    if(x%2==0 || x%3==0)return false;
    for(ll i=5;i*i<=x;i+=6)
    {
        if(x%i==0 ||x%(i+2)==0)return false;
    }
    return true;
}


#include<bits/stdc++.h>
using namespace std;

const long long mod = 1e9+7;
const int N = 5e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fr(l,m) for(int i=l;i<m;i++)

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll pwr(ll x,ll y);
bool isprime(ll x);

ll a[N],b[N];
bool x[N],y[N];

ll g(ll m)
{
    ll l=0,r=0;
    for(int i=m;i>=0;i--)
    {
        l+=pow(2,m-i)*x[i];
        r+=pow(2,m-i)*y[i];

    }
   // cout<<l<<" "<<r<<endl;
    return (r-l+1);
}
int bs(int x,int y,int k)
{
    int l=x,r=y;
    while(l<r)
    {
       // cout<<l<<' '<<r<<endl;
        int mid=(l+(r-l)/2);
        if(a[mid]<k)
        {
            l=mid+1;
        }
        else
        {
            r=mid;
        }
    }
    if(l>y){return y;}
    if(a[l]<=k){return l;}
    else return -1;
}

int main()
{
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

// Code Here
int n,k;
cin>>n>>k;
string s,t;
cin>>s>>t;
fr(0,n)
{
    if(s[i]=='b'){x[i]=1;}
    if(t[i]=='b'){y[i]=1;}
}
fr(0,n)
{
   a[i] = g(i);
   if(i==0){b[i]=a[i];continue;}
   b[i]=(b[i-1]+a[i]);
}

    int p=bs(0,n-1,k);
   ll sum=0;
if(p==-1)
{
    sum=k*(n);
}
else
{
    sum+=b[p];
    sum+=k*(n-p-1);
}
cout<<sum<<endl;
return 0;
}

/////////
/////////
/////////
ll pwr(ll x,ll y)
{
    ll ans=1;
    x=x%mod;
    while(y>0){
    if(y&1)ans=(x*ans)%mod;
    x=(x*x)%mod;
    y=y/2;
    }
    return ans;
}
bool isprime(ll x)
{
    if(x<2)return false;
    if(x<4)return true;
    if(x%2==0 || x%3==0)return false;
    for(ll i=5;i*i<=x;i+=6)
    {
        if(x%i==0 ||x%(i+2)==0)return false;
    }
    return true;
}


#include<bits/stdc++.h>
using namespace std;

const long long mod = 1e9+7;
const int N = 5e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fr(l,m) for(int i=l;i<m;i++)

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll pwr(ll x,ll y);
bool isprime(ll x);

ll a[N],b[N],c[N];
bool x[N],y[N];

int bs(int x,int y,int k)
{
    int l=x,r=y;
    while(l<r)
    {
       // cout<<l<<' '<<r<<endl;
        int mid=(l+(r-l)/2);
        if(a[mid]<k)
        {
            l=mid+1;
        }
        else
        {
            r=mid;
        }
    }
    if(l>y){return y;}
    if(a[l]>k){if(l==x)return -1;else return l-1;}
    return l;
}

int main()
{
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

// Code Here
int n,k,temp=0;
cin>>n>>k;
string s,t;
cin>>s>>t;
fr(0,n)
{
    if(s[i]=='b'){x[i]=1;}
    if(t[i]=='b'){y[i]=1;}
    c[i]=(temp*2+y[i]-x[i]);
    temp=c[i];
}
fr(0,n)
{
   a[i] =(c[i]+1);
   if(i==0){b[i]=a[i]; continue;}
   b[i]=(b[i-1]+a[i]);

}
    int p=bs(0,n-1,k);

   ll sum=0;
if(p==-1)
{
    sum=k*(n);
}
else
{
    sum+=b[p];
    sum+=k*(n-p-1);
}
cout<<sum<<endl;
return 0;
}

/////////
/////////
/////////
ll pwr(ll x,ll y)
{
    ll ans=1;
    x=x%mod;
    while(y>0){
    if(y&1)ans=(x*ans)%mod;
    x=(x*x)%mod;
    y=y/2;
    }
    return ans;
}
bool isprime(ll x)
{
    if(x<2)return false;
    if(x<4)return true;
    if(x%2==0 || x%3==0)return false;
    for(ll i=5;i*i<=x;i+=6)
    {
        if(x%i==0 ||x%(i+2)==0)return false;
    }
    return true;
}


#include<bits/stdc++.h>
using namespace std;

const long long mod = 1e9+7;
const int N = 5e5+5;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fr(l,m) for(int i=l;i<m;i++)

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll pwr(ll x,ll y);
bool isprime(ll x);

ll a[N],b[N],c[N];
bool x[N],y[N];

ll bs(int x,int y,int k)
{
    int l=x,r=y;
    while(l<r)
    {
       // cout<<l<<' '<<r<<endl;
        int mid=(l+(r-l)/2);
        if(a[mid]<k)
        {
            l=mid+1;
        }
        else
        {
            r=mid;
        }
    }
    if(l>y){return y;}
    if(a[l]>k){if(l==x)return -1;else return l-1;}
    return l;
}

int main()
{
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

// Code Here
ll n,k,temp=0;
cin>>n>>k;
string s,t;
cin>>s>>t;
fr(0,n)
{
    if(s[i]=='b'){x[i]=1;}
    if(t[i]=='b'){y[i]=1;}
    c[i]=(temp*2+y[i]-x[i]);
    temp=c[i]++;
}
if(k==1){cout<<n<<endl;return 0 ;}

ll sum=0;
temp=1;
fr(0,n)
{

    if(c[i]<=k){sum+=c[i];temp=c[i];}
    else
    {

        sum+=min(temp,k);

    }
}

/*
ll p=bs(0,n-1,k);
ll sum=0;
if(p==-1)
{
    sum=k*(n);
}
else
{
    sum+=b[p];
    sum+=k*(n-p-1);
}
*/

cout<<sum<<endl;
return 0;
}

/////////
/////////
/////////
ll pwr(ll x,ll y)
{
    ll ans=1;
    x=x%mod;
    while(y>0){
    if(y&1)ans=(x*ans)%mod;
    x=(x*x)%mod;
    y=y/2;
    }
    return ans;
}
bool isprime(ll x)
{
    if(x<2)return false;
    if(x<4)return true;
    if(x%2==0 || x%3==0)return false;
    for(ll i=5;i*i<=x;i+=6)
    {
        if(x%i==0 ||x%(i+2)==0)return false;
    }
    return true;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define For(i,n) for(int i=0;i<n;i++)
#define Fre(i,a,b) for(int i = a; i < b; i++)
#define sf(n) scanf("%d", &n)
#define sff(a,b) scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pfn(n) printf("%d\n", n)
#define pfs(n) printf("%d ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define READ freopen("in.txt", "r", stdin)
#define WRITE freopen("out.txt", "w", stdout)
#define sz size()
#define number_of_digit(n) __builtin_ffs(n);
#define ll long long
#define T int
#define ld long double
inline void print(T n)
{
	if (n == 0)
	{
		putchar('0');
		putchar('\n');
	}
	else if (n == -1)
	{
		putchar('-');
		putchar('1');
		putchar('\n');
	}
	else
	{
		char buf[11];
		buf[10] = '\n';
		int i = 9;
		while (n)
		{
			buf[i--] = n % 10 + '0';
			n /= 10;
		}
		while (buf[i] != '\n')
			putchar(buf[++i]);
	}
}
int read()
{
       int cc = getc(stdin);
       for (;cc < '0' || cc > '9';)  cc = getc(stdin);
       int ret = 0;
       for (;cc >= '0' && cc <= '9';)
       {
          ret = ret * 10 + cc - '0';
          cc = getc(stdin);
       }
      return ret;
}
ll power(ll num,ll g)
{
	if(g==0)return 1;

	if(g%2==1)return (num*power((num*num)%mod,g/2))%mod;
	return power((num*num)%mod,g/2);
}
vector<pair<ll,ll> > vec[300005];
ll a[300005];
ll ans;
ll dfs(int index,int parent)
{
	ll sum=a[index];
	ll sum1=0,sum2=0;
	For(i,vec[index].size())
	{
		if(vec[index][i].ff==parent)continue;
		ll g=dfs(vec[index][i].ff,index);
		g-=vec[index][i].ss;
		if(sum1>=g)
		{
			sum2=sum1;
			sum1=g;
		}
		else sum2=max(sum2,g);
	}
	return ans=max(ans,sum2+sum1+sum);
	return sum1+sum;
}
int main()
{
	ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
  	cout.tie(NULL);

  	ll n,k;
  	cin>>n>>k;
  	string s,t;
  	cin>>s>>t;
  	vector<string> vec;
  	vec.pb(s);
  	vec.pb(t);
  	sort(vec.begin(),vec.end());
  	s=vec[0];
  	t=vec[1];
  	ll ans=0;
  	ll x=0;

  	For(i,n)
  	{
  		if(s[i]==t[i])
  		{
  			x*=(ll)2;
  		}
  		else if(s[i]=='a')
  		{
  			x*=(ll)2;
  			x++;
  		}
  		else
  		{
  			x*=(ll)2;
  			x--;
  			x=max(x,(ll)0);
  		}
  		x=min(x,k-1);
  		ans+=x+1;
  		//cout<<ans<<" "<<x<<endl;
  	}
  	cout<<ans<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define For(i,n) for(int i=0;i<n;i++)
#define Fre(i,a,b) for(int i = a; i < b; i++)
#define sf(n) scanf("%d", &n)
#define sff(a,b) scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pfn(n) printf("%d\n", n)
#define pfs(n) printf("%d ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define READ freopen("in.txt", "r", stdin)
#define WRITE freopen("out.txt", "w", stdout)
#define sz size()
#define number_of_digit(n) __builtin_ffs(n);
#define ll long long
#define T int
#define ld long double
inline void print(T n)
{
	if (n == 0)
	{
		putchar('0');
		putchar('\n');
	}
	else if (n == -1)
	{
		putchar('-');
		putchar('1');
		putchar('\n');
	}
	else
	{
		char buf[11];
		buf[10] = '\n';
		int i = 9;
		while (n)
		{
			buf[i--] = n % 10 + '0';
			n /= 10;
		}
		while (buf[i] != '\n')
			putchar(buf[++i]);
	}
}
int read()
{
       int cc = getc(stdin);
       for (;cc < '0' || cc > '9';)  cc = getc(stdin);
       int ret = 0;
       for (;cc >= '0' && cc <= '9';)
       {
          ret = ret * 10 + cc - '0';
          cc = getc(stdin);
       }
      return ret;
}
ll power(ll num,ll g)
{
	if(g==0)return 1;

	if(g%2==1)return (num*power((num*num)%mod,g/2))%mod;
	return power((num*num)%mod,g/2);
}
vector<pair<ll,ll> > vec[300005];
ll a[300005];
ll ans;
ll dfs(int index,int parent)
{
	ll sum=a[index];
	ll sum1=0,sum2=0;
	For(i,vec[index].size())
	{
		if(vec[index][i].ff==parent)continue;
		ll g=dfs(vec[index][i].ff,index);
		g-=vec[index][i].ss;
		if(sum1>=g)
		{
			sum2=sum1;
			sum1=g;
		}
		else sum2=max(sum2,g);
	}
	return ans=max(ans,sum2+sum1+sum);
	return sum1+sum;
}
int main()
{
	ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
  	cout.tie(NULL);

  	ll n,k;
  	cin>>n>>k;
  	string s,t;
  	cin>>s>>t;
  	ll ans=0;
  	ll x=0;
  	For(i,n)
  	{
  		if(s[i]==t[i])
  		{
  			x*=2;
  		}
  		else if(s[i]=='a')
  		{
  			x*=2;
  			x++;
  		}
  		else
  		{
  			x*=2;
  			x--;
  		}
  		x=min(x,k-1);
  		ans+=x+1;
  	//	cout<<x<<endl;
  	}
  	cout<<ans<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define For(i,n) for(int i=0;i<n;i++)
#define Fre(i,a,b) for(int i = a; i < b; i++)
#define sf(n) scanf("%d", &n)
#define sff(a,b) scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pfn(n) printf("%d\n", n)
#define pfs(n) printf("%d ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define READ freopen("in.txt", "r", stdin)
#define WRITE freopen("out.txt", "w", stdout)
#define sz size()
#define number_of_digit(n) __builtin_ffs(n);
#define ll long long
#define T int
#define ld long double
inline void print(T n)
{
	if (n == 0)
	{
		putchar('0');
		putchar('\n');
	}
	else if (n == -1)
	{
		putchar('-');
		putchar('1');
		putchar('\n');
	}
	else
	{
		char buf[11];
		buf[10] = '\n';
		int i = 9;
		while (n)
		{
			buf[i--] = n % 10 + '0';
			n /= 10;
		}
		while (buf[i] != '\n')
			putchar(buf[++i]);
	}
}
int read()
{
       int cc = getc(stdin);
       for (;cc < '0' || cc > '9';)  cc = getc(stdin);
       int ret = 0;
       for (;cc >= '0' && cc <= '9';)
       {
          ret = ret * 10 + cc - '0';
          cc = getc(stdin);
       }
      return ret;
}
ll power(ll num,ll g)
{
	if(g==0)return 1;

	if(g%2==1)return (num*power((num*num)%mod,g/2))%mod;
	return power((num*num)%mod,g/2);
}
vector<pair<ll,ll> > vec[300005];
ll a[300005];
ll ans;
ll dfs(int index,int parent)
{
	ll sum=a[index];
	ll sum1=0,sum2=0;
	For(i,vec[index].size())
	{
		if(vec[index][i].ff==parent)continue;
		ll g=dfs(vec[index][i].ff,index);
		g-=vec[index][i].ss;
		if(sum1>=g)
		{
			sum2=sum1;
			sum1=g;
		}
		else sum2=max(sum2,g);
	}
	return ans=max(ans,sum2+sum1+sum);
	return sum1+sum;
}
int main()
{
	ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
  	cout.tie(NULL);

  	ll n,k;
  	cin>>n>>k;
  	string s,t;
  	cin>>s>>t;
  	vector<string> vec;
  	vec.pb(s);
  	vec.pb(t);
  	sort(vec.begin(),vec.end());
  	s=vec[0];
  	t=vec[1];
  	ll ans=0;
  	ll x=0;
  	For(i,n)
  	{
  		if(s[i]==t[i])
  		{
  			x*=(ll)2;
  			x++;
  		}
  		else if(s[i]=='a')
  		{
  			x*=(ll)2;
  			x++;
  			x++;
  		}
  		else
  		{
  			x*=(ll)2;
  		}
  		x=min(x,k-1);
  		ans+=x+1;
  	}
  	cout<<ans<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define For(i,n) for(int i=0;i<n;i++)
#define Fre(i,a,b) for(int i = a; i < b; i++)
#define sf(n) scanf("%d", &n)
#define sff(a,b) scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pfn(n) printf("%d\n", n)
#define pfs(n) printf("%d ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define READ freopen("in.txt", "r", stdin)
#define WRITE freopen("out.txt", "w", stdout)
#define sz size()
#define number_of_digit(n) __builtin_ffs(n);
#define ll long long
#define T int
#define ld long double
inline void print(T n)
{
	if (n == 0)
	{
		putchar('0');
		putchar('\n');
	}
	else if (n == -1)
	{
		putchar('-');
		putchar('1');
		putchar('\n');
	}
	else
	{
		char buf[11];
		buf[10] = '\n';
		int i = 9;
		while (n)
		{
			buf[i--] = n % 10 + '0';
			n /= 10;
		}
		while (buf[i] != '\n')
			putchar(buf[++i]);
	}
}
int read()
{
       int cc = getc(stdin);
       for (;cc < '0' || cc > '9';)  cc = getc(stdin);
       int ret = 0;
       for (;cc >= '0' && cc <= '9';)
       {
          ret = ret * 10 + cc - '0';
          cc = getc(stdin);
       }
      return ret;
}
ll power(ll num,ll g)
{
	if(g==0)return 1;

	if(g%2==1)return (num*power((num*num)%mod,g/2))%mod;
	return power((num*num)%mod,g/2);
}
vector<pair<ll,ll> > vec[300005];
ll a[300005];
ll ans;
ll dfs(int index,int parent)
{
	ll sum=a[index];
	ll sum1=0,sum2=0;
	For(i,vec[index].size())
	{
		if(vec[index][i].ff==parent)continue;
		ll g=dfs(vec[index][i].ff,index);
		g-=vec[index][i].ss;
		if(sum1>=g)
		{
			sum2=sum1;
			sum1=g;
		}
		else sum2=max(sum2,g);
	}
	return ans=max(ans,sum2+sum1+sum);
	return sum1+sum;
}
int main()
{
	ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
  	cout.tie(NULL);

  	ll n,k;
  	cin>>n>>k;
  	string s,t;
  	cin>>s>>t;
  	vector<string> vec;
  	vec.pb(s);
  	vec.pb(t);
  	sort(vec.begin(),vec.end());
  	s=vec[0];
  	t=vec[1];
  	ll ans=0;
  	ll x=0;
  	if(k==1)
  	{
  		cout<<n<<endl;
  		return 0;
	  }
  	For(i,n)
  	{
  		if(s[i]==t[i])
  		{
  			x*=(ll)2;
  		}
  		else if(s[i]=='a')
  		{
  			x*=(ll)2;
  			x++;
  		}
  		else
  		{
  			x*=(ll)2;
  			x--;
  			//x=max(x,(ll)0);
  		}
  		x=min(x,k-1);
  		ans+=x+1;
  		//cout<<ans<<" "<<x<<endl;
  	}
  	cout<<ans<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define For(i,n) for(int i=0;i<n;i++)
#define Fre(i,a,b) for(int i = a; i < b; i++)
#define sf(n) scanf("%d", &n)
#define sff(a,b) scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pfn(n) printf("%d\n", n)
#define pfs(n) printf("%d ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define READ freopen("in.txt", "r", stdin)
#define WRITE freopen("out.txt", "w", stdout)
#define sz size()
#define number_of_digit(n) __builtin_ffs(n);
#define ll long long
#define T int
#define ld long double
inline void print(T n)
{
	if (n == 0)
	{
		putchar('0');
		putchar('\n');
	}
	else if (n == -1)
	{
		putchar('-');
		putchar('1');
		putchar('\n');
	}
	else
	{
		char buf[11];
		buf[10] = '\n';
		int i = 9;
		while (n)
		{
			buf[i--] = n % 10 + '0';
			n /= 10;
		}
		while (buf[i] != '\n')
			putchar(buf[++i]);
	}
}
int read()
{
       int cc = getc(stdin);
       for (;cc < '0' || cc > '9';)  cc = getc(stdin);
       int ret = 0;
       for (;cc >= '0' && cc <= '9';)
       {
          ret = ret * 10 + cc - '0';
          cc = getc(stdin);
       }
      return ret;
}
ll power(ll num,ll g)
{
	if(g==0)return 1;

	if(g%2==1)return (num*power((num*num)%mod,g/2))%mod;
	return power((num*num)%mod,g/2);
}
vector<pair<ll,ll> > vec[300005];
ll a[300005];
ll ans;
ll dfs(int index,int parent)
{
	ll sum=a[index];
	ll sum1=0,sum2=0;
	For(i,vec[index].size())
	{
		if(vec[index][i].ff==parent)continue;
		ll g=dfs(vec[index][i].ff,index);
		g-=vec[index][i].ss;
		if(sum1>=g)
		{
			sum2=sum1;
			sum1=g;
		}
		else sum2=max(sum2,g);
	}
	return ans=max(ans,sum2+sum1+sum);
	return sum1+sum;
}
int main()
{
	ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
  	cout.tie(NULL);

  	ll n,k;
  	cin>>n>>k;
  	string s,t;
  	cin>>s>>t;
  	vector<string> vec;
  	vec.pb(s);
  	vec.pb(t);
  	sort(vec.begin(),vec.end());
  	s=vec[0];
  	t=vec[1];
  	ll ans=0;
  	ll x=0;
  	For(i,n)
  	{
  		if(s[i]==t[i])
  		{
  			x*=2;
  		}
  		else if(s[i]=='a')
  		{
  			x*=2;
  			x++;
  		}
  		else
  		{
  			x*=2;
  			x--;
  		}
  		x=min(x,k-1);
  		ans+=x+1;
  	}
  	cout<<ans<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define For(i,n) for(int i=0;i<n;i++)
#define Fre(i,a,b) for(int i = a; i < b; i++)
#define sf(n) scanf("%d", &n)
#define sff(a,b) scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pfn(n) printf("%d\n", n)
#define pfs(n) printf("%d ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define READ freopen("in.txt", "r", stdin)
#define WRITE freopen("out.txt", "w", stdout)
#define sz size()
#define number_of_digit(n) __builtin_ffs(n);
#define ll long long
#define T int
#define ld long double
inline void print(T n)
{
	if (n == 0)
	{
		putchar('0');
		putchar('\n');
	}
	else if (n == -1)
	{
		putchar('-');
		putchar('1');
		putchar('\n');
	}
	else
	{
		char buf[11];
		buf[10] = '\n';
		int i = 9;
		while (n)
		{
			buf[i--] = n % 10 + '0';
			n /= 10;
		}
		while (buf[i] != '\n')
			putchar(buf[++i]);
	}
}
int read()
{
       int cc = getc(stdin);
       for (;cc < '0' || cc > '9';)  cc = getc(stdin);
       int ret = 0;
       for (;cc >= '0' && cc <= '9';)
       {
          ret = ret * 10 + cc - '0';
          cc = getc(stdin);
       }
      return ret;
}
ll power(ll num,ll g)
{
	if(g==0)return 1;

	if(g%2==1)return (num*power((num*num)%mod,g/2))%mod;
	return power((num*num)%mod,g/2);
}
vector<pair<ll,ll> > vec[300005];
ll a[300005];
ll ans;
ll dfs(int index,int parent)
{
	ll sum=a[index];
	ll sum1=0,sum2=0;
	For(i,vec[index].size())
	{
		if(vec[index][i].ff==parent)continue;
		ll g=dfs(vec[index][i].ff,index);
		g-=vec[index][i].ss;
		if(sum1>=g)
		{
			sum2=sum1;
			sum1=g;
		}
		else sum2=max(sum2,g);
	}
	return ans=max(ans,sum2+sum1+sum);
	return sum1+sum;
}
int main()
{
	ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
  	cout.tie(NULL);

  	ll n,k;
  	cin>>n>>k;
  	string s,t;
  	cin>>s>>t;
  	vector<string> vec;
  	vec.pb(s);
  	vec.pb(t);
  	sort(vec.begin(),vec.end());
  	s=vec[0];
  	t=vec[1];
  	ll ans=0;
  	ll x=0;
  	For(i,n)
  	{
  		if(s[i]==t[i])
  		{
  			x*=(ll)2;
  		}
  		else if(s[i]=='a')
  		{
  			x*=(ll)2;
  			x++;
  		}
  		else
  		{
  			x*=(ll)2;
  			x--;
  		}
  		x=min(x,k-1);
  		ans+=x+1;
  	}
  	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n,k;
    string s,t;
    cin>>n>>k>>s>>t;
    long long ans=0;
    long long cnt=1;
    for(int i=0;i<n;i++)
    {
        cnt=cnt*2;
        if(s[i]=='b') cnt--;
        if(t[i]=='a') cnt--;
        if(cnt>=k)
        {
            ans+=k*(n-i);
            break;
        }
        ans+=cnt;
    }
    cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,k;
    string s,t;
    cin>>n>>k>>s>>t;
    long long ans=0;
    long long cnt=1;
    for(int i=0;i<n;i++)
    {
        cnt=cnt*2;
        if(s[i]=='b') cnt--;
        if(t[i]=='a') cnt--;
        if(cnt>=k)
        {
            ans+=k*(n-i);
            break;
        }
        ans+=cnt;
    }
    cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n,k;
    string s,t;
    cin>>n>>k>>s>>t;
    int ans=0;
    long long cnt=1;
    for(int i=0;i<n;i++)
    {
        cnt=cnt*2;
        if(s[i]=='b') cnt--;
        if(t[i]=='a') cnt--;
        if(cnt>=k)
        {
            ans+=k*(n-i);
            break;
        }
        ans+=cnt;
    }
    cout<<ans<<endl;
}


#include <iostream>
#include <cstdlib>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
using namespace std;
const int maxn=500010;
int n,k,a[maxn],b[maxn],s;
char aa[maxn],bb[maxn];
long long ans,n1,n2,n3;
int main()
{
	scanf("%d%d%s%s",&n,&k,aa+1,bb+1); s=n+1;
	for (int i=1;i<=n;i++) a[i]=(aa[i]=='b'),b[i]=(bb[i]=='b');
	for (int i=1;i<=n;i++) if (a[i]==b[i]) ans++;else {s=i; break;}
	if (s<n+1) {n1=1; n3=1;}
	for (int i=s;i<=n;i++)
	if (n1+n2+n3<k)
	{
   		ans+=n1+n2+n3; n2*=2;
   		if (a[i+1]==0) n2++;
   		if (b[i+1]==1) n2++;
	}else ans+=k;
	printf("%lld\n",ans);
return 0;
}


#include <iostream>
#include <cstdlib>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
using namespace std;
const int maxn=500010;
int n,k,a[maxn],b[maxn],s;
char aa[maxn],bb[maxn];
long long ans,n1,n2,n3;
int main()
{
	scanf("%d%d%s%s",&n,&k,aa+1,bb+1); s=n+1;
	for (int i=1;i<=n;i++) a[i]=(aa[i]=='b'),b[i]=(bb[i]=='b');
	for (int i=1;i<=n;i++) if (a[i]==b[i]) ans++;else {s=i; break;}
	if (s<n+1) {n1=1; n3=1;}
	for (int i=s;i<=n;i++)
	if (n1+n2+n3<k)
	{
   		ans+=min(1ll*k,n1+n2+n3); n2*=2;
   		if (a[i]==0 && a[i+1]==0) n2++;
   		if (b[i]==1 && b[i+1]==1) n2++;
	}else ans+=k;
	printf("%lld\n",ans);
return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
char s1[1000001],s2[1000001];
ll n,m,ans;
void dfs(int x,int sum,int f1,int f2){
	if(!sum)sum=1;
	if(x>1)ans+=sum-1;
	if(x>n||sum<=1)return;
	if(f1){
		if(f2){
			if(s1[x]==s2[x])dfs(x+1,sum,f1,f2);
			 else{
			 	dfs(x+1,sum/2,f1,0);
			 	dfs(x+1,sum-sum/2,0,f2);
			 }
		}
		 else{
		 	if(s1[x]=='b')dfs(x+1,sum,f1,f2);
		 	 else{
		 	 	dfs(x+1,sum/2,f1,0);
			 	dfs(x+1,sum-sum/2,0,f2);
			  }
		 }
	}
	 else{
	 	if(f2){
	 		if(s2[x]=='a')dfs(x+1,sum,f1,f2);
	 		 else{
	 		 	dfs(x+1,sum/2,0,0);
	 		 	dfs(x+1,sum-sum/2,0,1);
			  }
		 }
		  else{
		  	dfs(x+1,sum/2,0,0);
	 		dfs(x+1,sum-sum/2,0,0);
		  }
	 }
}
int main(){
	ll i,t,k,s;
	scanf("%lld%lld",&n,&m);
	scanf("%s",s1+1);
	scanf("%s",s2+1);
	dfs(1,m,1,1);
	printf("%lld",n*m-ans);
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
char s1[1000001],s2[1000001];
ll n,m,ans;
void dfs(ll x,ll sum,ll f1,ll f2){
	if(!sum)sum=1;
	if(x>1)ans+=sum-1;
	if(x>n||sum<=1)return;
	if(f1){
		if(f2){
			if(s1[x]==s2[x])dfs(x+1,sum,f1,f2);
			 else{
			 	dfs(x+1,sum/2,f1,0);
			 	dfs(x+1,sum-sum/2,0,f2);
			 }
		}
		 else{
		 	if(s1[x]=='b')dfs(x+1,sum,f1,f2);
		 	 else{
		 	 	dfs(x+1,sum/2,f1,0);
			 	dfs(x+1,sum-sum/2,0,f2);
			  }
		 }
	}
	 else{
	 	if(f2){
	 		if(s2[x]=='a')dfs(x+1,sum,f1,f2);
	 		 else{
	 		 	dfs(x+1,sum/2,0,0);
	 		 	dfs(x+1,sum-sum/2,0,1);
			  }
		 }
		  else{
		  	dfs(x+1,sum/2,0,0);
	 		dfs(x+1,sum-sum/2,0,0);
		  }
	 }
}
int main(){
	ll i,t,k,s;
	scanf("%lld%lld",&n,&m);
	scanf("%s",s1+1);
	scanf("%s",s2+1);
	dfs(1,m,1,1);
	printf("%lld",n*m-ans);
}


/////////////////////////////////
//////**DOMINIK___KOWALCZYK**////
/////////////////////////////////

#include <bits/stdc++.h>

using namespace std;

#define boost ios_base::sync_with_stdio(0);
#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define ELO exit(0)

typedef long long ll;

int main()
{
	boost;

	ll n , k;
	cin >> n >> k;

	string a , b;
	cin >> a >> b;

	if (k == 1 or a == b)
	{
		cout << n;
		ELO;
	}

	ll res, warstwa;

	warstwa = b[0] - a[0] + 1;
	warstwa = min(warstwa, k);

	res = warstwa;

	bool teSame = (b[0] == a[0]);

	ll srodek = 0;

	for (int i = 1; i < n; i++)
	{
		//cerr << "res : " <<  res << "\n";
		//cerr << "w : " << warstwa << "\n";
		if (teSame)
		{
			warstwa = b[i] - a[i] + 1;
			teSame = (b[i] == a[i]);
		}
		else
		{
			ll gora = 'b' - a[i];
			ll dol = b[i] - 'a';

			//cerr << "g , d : " << gora << " " << dol << "\n";
			warstwa = 2 +  (2 * (warstwa - 2));
			warstwa += gora + dol;
		}

		warstwa = min(warstwa, k);
		res += warstwa;
	}
	//cerr << "res : " <<  res << "\n";
	//cerr << "w : " << warstwa << "\n";

	cout << res;

	ELO;
}


/////////////////////////////////
//////**DOMINIK___KOWALCZYK**////
/////////////////////////////////

#include <bits/stdc++.h>

using namespace std;

#define boost ios_base::sync_with_stdio(0);
#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define ELO exit(0)

typedef long long ll;

int main()
{
	boost;

	ll n , k;
	cin >> n >> k;

	string a , b;
	cin >> a >> b;

	if (k == 1 or a == b)
	{
		cout << n;
		ELO;
	}

	ll res, warstwa;

	warstwa = b[0] - a[0] + 1;
	warstwa = min(warstwa,k);

	res = warstwa;

	bool teSame = (b[0] == a[0]);

	ll srodek = 0;

	for (int i = 1; i < n; i++)
	{
		//cerr << "res : " <<  res << "\n";
		//cerr << "w : " << warstwa << "\n";
		if (teSame)
		{
			warstwa = b[i] - a[i] + 1;
			teSame = (b[i] == a[i]);
		}
		else
		{
			ll gora = 'b' - a[i];
			ll dol = b[i] - 'a';

			warstwa += (2 * (warstwa - 2));
			warstwa += gora + dol;
		}

		warstwa = min(warstwa, k);
		res += warstwa;
	}

	cout << res;

	ELO;
}


#pragma GCC optimize("Ofast")

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <fstream>
#include <stdio.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <iomanip>
#include <random>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <bitset>
#include <sstream>

using namespace std;

#define mp make_pair
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define all_(x) x.rbegin(), x.rend()
#define multi_test 0

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int INF = 2e9 + 9;
const ll INF1 = 1e18 + 9;
const ll MAXN = 3e5 + 7;
const ll MAXN1 = 1 << 11;
const ll MAXN2 = 4e6 + 9;
const ll MOD = 1e9 + 7;
const ll MOD1 = 1e9 + 9;
const ll ALPH = 50;
const ll PW1 = 239;
const ll PW2 = 199;
const ll PW3 = 193;
const ll PW4 = 117;
const ld EPS = 1e-9;
const ll BLOCK = 3684;
const ll BLOCK1 = 1 << 9;

void solve();

signed main(){
	srand('a' + 'l' + 'e' + 'x' + 'X' + '5' + '1' + '2');
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifdef _DEBUG
#define MAXN 2007
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif // _DEBUG
	int q = 1;
	if (multi_test) cin >> q;
	while (q--) solve();
}

/*-------------------------------------------------------------------------------------------------------------*/

void solve() {
	ll n, k, cnt = 1, ans = 0;
	string s, t;
	cin >> n >> k >> s >> t;
	for (int i = 0; i < n; ++i) {
		cnt = min(k * 2, (cnt - 2) * 2 + 2 + int(s[i] == 'a') + int(t[i] == 'b'));
		ans += min(k, cnt);
	}
	cout << ans;
}


#pragma GCC optimize("Ofast")

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <fstream>
#include <stdio.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <iomanip>
#include <random>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <bitset>
#include <sstream>

using namespace std;

#define mp make_pair
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define all_(x) x.rbegin(), x.rend()
#define multi_test 0

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int INF = 2e9 + 9;
const ll INF1 = 1e18 + 9;
const ll MAXN = 3e5 + 7;
const ll MAXN1 = 1 << 11;
const ll MAXN2 = 4e6 + 9;
const ll MOD = 1e9 + 7;
const ll MOD1 = 1e9 + 9;
const ll ALPH = 50;
const ll PW1 = 239;
const ll PW2 = 199;
const ll PW3 = 193;
const ll PW4 = 117;
const ld EPS = 1e-9;
const ll BLOCK = 3684;
const ll BLOCK1 = 1 << 9;

void solve();

signed main(){
	srand('a' + 'l' + 'e' + 'x' + 'X' + '5' + '1' + '2');
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifdef _DEBUG
#define MAXN 2007
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif // _DEBUG
	int q = 1;
	if (multi_test) cin >> q;
	while (q--) solve();
}

/*-------------------------------------------------------------------------------------------------------------*/

void solve() {
	ll n, k, cnt = 1, ans = 0;
	string s, t;
	cin >> n >> k >> s >> t;
	for (int i = 0; i < n; ++i) {
		cnt = min(k, (cnt - 2) * 2 + 2 + int(s[i] == 'a') + int(t[i] == 'b'));
		ans += cnt;
	}
	cout << ans;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define v vector

int main() {
    ll n, k;
    string s, t;
    cin >> n >> k >> s >> t;
    v<ll> comb(n + 1, 0);
    comb[0] = 1;

    for(ll i = 0; i < n; i ++) {
        comb[i+1] = 2 * comb[i];
        if(s[i] == 'b') comb[i+1] --;
        if(t[i] == 'a') comb[i+1] --;
        comb[i+1] = min(comb[i+1], (ll)1e15);
    }

    ll ans = 0;
    for(ll i = 1; i <= n; i++) {
        ans += min(comb[i], k);
    }

    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define v vector

int main() {
    ll n, k;
    string s, t;
    cin >> n >> k >> s >> t;
    v<ll> comb(n + 1, 0);
    comb[0] = 1;

    for(ll i = 0; i < n; i ++) {
        comb[i+1] = 2 * comb[i];
        if(s[i] == 'b') comb[i+1] --;
        if(t[i] == 'a') comb[i+1] --;
        comb[i+1] = min(comb[i+1], k);
    }

    ll ans = 0;
    for(ll i = 1; i <= n; i++) {
        ans += comb[i];
    }

    cout << ans << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int n, k;
string str1, str2;
const int MAXN = 500 * 1000;
bool arr1[MAXN + 10], arr2[MAXN + 10];

void f()
{
    for (int i = 0; i < n; i ++)
    {
        if (str1[i] == 'b')
            arr1[i] = 1;
        if (str2[i] == 'b')
            arr2[i] = 1;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k >> str1 >> str2;
    f();
    long long s1 = 0, s2 = 0, ans  = 0;
    for (int i = 0; i < n; i ++)
    {
        s1 <<= 1, s2 <<= 1;
        s1 |= arr1[i], s2 |= arr2[i];
        ans += min((long long)k, (s2 - s1 + 1));
    }
    cout << ans << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int n, k;
string str1, str2;
const int MAXN = 500 * 1000;
bool arr1[MAXN + 10], arr2[MAXN + 10];

void f()
{
    for (int i = 0; i < n; i ++)
    {
        if (str1[i] == 'b')
            arr1[i] = 1;
        if (str2[i] == 'b')
            arr2[i] = 1;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k >> str1 >> str2;
    f();
    long long s1 = 0, s2 = 0, ans  = 0;
    for (int i = 0; i < n; i ++)
    {
        if (s2 - s1 + 1 < k)
        {
            s1 <<= 1, s2 <<= 1;
            s1 |= arr1[i], s2 |= arr2[i];
            ans += min((long long)k, s2 - s1 + 1);
        }
        else
        {
            ans += k;
        }
    }
    cout << ans << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int n, k;
string str1, str2;
const int MAXN = 500 * 1000;
bool arr1[MAXN + 10], arr2[MAXN + 10];

void f()
{
    for (int i = 0; i < n; i ++)
    {
        if (str1[i] == 'b')
            arr1[i] = 1;
        if (str2[i] == 'b')
            arr2[i] = 1;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k >> str1 >> str2;
    f();
    long long s1 = 0, s2 = 0, ans  = 0;
    for (int i = 0; i < n; i ++)
    {
        s1 <<= 1, s2 <<= 1;
        s1 |= arr1[i], s2 |= arr2[i];
        ans += min(k, (s2 - s1 + 1));
    }
    cout << ans << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int n, k;
string str1, str2;
const int MAXN = 500 * 1000;
bool arr1[MAXN + 10], arr2[MAXN + 10];

void f()
{
    for (int i = 0; i < n; i ++)
    {
        if (str1[i] == 'b')
            arr1[i] = 1;
        if (str2[i] == 'b')
            arr2[i] = 1;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k >> str1 >> str2;
    f();
    int s1 = 0, s2 = 0;
    long long ans  = 0;
    for (int i = 0; i < n; i ++)
    {
        s1 <<= 1, s2 <<= 1;
        s1 |= arr1[i], s2 |= arr2[i];
        ans += min(k, (s2 - s1 + 1));
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main(){
   ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
#ifdef LOCAL
   freopen("input.txt", "r", stdin);
#endif
   int n , k;
   cin >> n >> k;
   string s , t;
   cin >> s >> t;

   int max_strings = 1;
   long long rs = 0;
   for(int i = 0 ; i < n ; ++i){
      max_strings <<= 1;
      max_strings -= s[i] - 'a';
      max_strings -= 'b' - t[i];
      if(max_strings >= k){
         for(int j = i ; j < n ; ++j)
            rs += k;
         break;
      }
      rs += max_strings;
   }
   cout << rs << "\n";
}


#include <bits/stdc++.h>
using namespace std;

int main(){
   ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
#ifdef LOCAL
   freopen("input.txt", "r", stdin);
#endif
   int n , k;
   cin >> n >> k;
   string s , t;
   cin >> s >> t;

   int max_strings = 1;
   long long rs = 0;
   for(int i = 0 ; i < n ; ++i){
      max_strings <<= 1;
      if(s[i] == 'b')
         max_strings--;
      if(t[i] == 'a')
         max_strings--;
      if(max_strings >= k){
         for(int j = i ; j < n ; ++j)
            rs += k;
         break;
      }
      rs += max_strings;
   }
   cout << rs << "\n";
}


/* Author haleyk10198 */
/* �@��:  haleyk10198 */
/* CF handle: haleyk100198*/
/* FOR ACM-ICPC WF*/
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

#define pb push_back

constexpr auto MOD = 1000000007LL;
constexpr auto LINF = (1LL << 60);
constexpr auto INF = 2147483647LL;
constexpr auto PI = 3.1415926535897932384626433;
constexpr auto EPS = 1E-9;

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> p) {
    out << p.first << ' ' << p.second;
    return out;
}

template<typename T1, typename T2>
istream &operator>>(istream &in, pair<T1, T2> &p) {
    in >> p.first >> p.second;
    return in;
}

template<typename T>
istream &operator>>(istream &in, vector<T> &v) {
    for (auto &x: v)
        in >> x;
    return in;
}

template<typename T>
ostream &operator<<(ostream &out, vector<T> v) {
    for (int i = 0; i < v.size(); i++)
        out << v[i] << (i + 1 == v.size() ? '\n' : ' ');
    out.flush();
    return out;
}

#if __cplusplus < 201703L
#define mp make_pair
#endif

int n, k;
ll res, cnt;

string s, t;

int main() {
#ifdef LOCAL
    freopen("../input.txt", "r", stdin);
//		freopen("output.txt","w",stdout);
    freopen("../debug.txt", "w", stderr);
#endif
    ios_base::sync_with_stdio(false);

    cin >> n >> k >> s >> t;

    cnt = 1;
    for(int i = 0; i < n; i++){
        cnt *= 2;
        cnt -= (s[i] == 'b');
        cnt -= (t[i] == 'a');

        cnt = min(cnt, (ll)k);
        res += cnt;
    }

    cout << res << endl;

    return 0;
}


/* Author haleyk10198 */
/* �@��:  haleyk10198 */
/* CF handle: haleyk100198*/
/* FOR ACM-ICPC WF*/
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

#define pb push_back

constexpr auto MOD = 1000000007LL;
constexpr auto LINF = (1LL << 60);
constexpr auto INF = 2147483647LL;
constexpr auto PI = 3.1415926535897932384626433;
constexpr auto EPS = 1E-9;

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> p) {
    out << p.first << ' ' << p.second;
    return out;
}

template<typename T1, typename T2>
istream &operator>>(istream &in, pair<T1, T2> &p) {
    in >> p.first >> p.second;
    return in;
}

template<typename T>
istream &operator>>(istream &in, vector<T> &v) {
    for (auto &x: v)
        in >> x;
    return in;
}

template<typename T>
ostream &operator<<(ostream &out, vector<T> v) {
    for (int i = 0; i < v.size(); i++)
        out << v[i] << (i + 1 == v.size() ? '\n' : ' ');
    out.flush();
    return out;
}

#if __cplusplus < 201703L
#define mp make_pair
#endif

int n, k;
ll res, cnt;

string s, t;

int main() {
#ifdef LOCAL
    freopen("../input.txt", "r", stdin);
//		freopen("output.txt","w",stdout);
    freopen("../debug.txt", "w", stderr);
#endif
    ios_base::sync_with_stdio(false);

    cin >> n >> k >> s >> t;

    cnt = 1;
    for(int i = 0; i < n; i++){
        cnt *= 2;
        cnt -= (s[i] == 'b');
        cnt -= (t[i] == 'a');

        cnt = min(cnt, (ll)k);
        cnt = max(cnt, 1LL);

        res += cnt;
    }

    cout << res << endl;

    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

#define ll long long

ll N, K;
string S, T;

int main() {

  cin >> N >> K >> S >> T;

  if (K == 1) {
    cout << N << endl;
    return 0;
  }

  int s = 0;
  while (s < N && S[s] == T[s]) s++;

  ll ans = N + (N-s);
  ll curr = 0;
  K -= 2;

  for (int i = s+1; i < N; i++) {
    if (S[i] == 'a') {
      curr++;
    }
    if (T[i] == 'b') {
      curr++;
    }
    ll d = min(K, curr);
    ans += d * (N-i);
    K -= d;
  }

  cout << ans << endl;

  return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

#define ll long long

ll N, K;
string S, T;

int main() {

  cin >> N >> K >> S >> T;

  if (K == 1) cout << N << endl;

  int s = 0;
  while (s < N && S[s] == T[s]) s++;

  ll ans = N + (N-s);
  ll curr = 0;

  K -= 2;

  for (int i = s+1; i < N; i++) {
    if (S[i] == 'a') {
      curr++;
    }
    if (T[i] == 'b') {
      curr++;
    }
    ll d = min(K, curr);
    ans += d * (N-i);
    K -= d;
  }

  cout << ans << endl;

  return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

#define ll long long

ll N, K;
string S, T;

int main() {

  cin >> N >> K >> S >> T;

  if (K == 1) {
    cout << N << endl;
    return 0;
  }

  int s = 0;
  while (s < N && S[s] == T[s]) s++;

  ll ans = N+(N-s);
  ll curr = 0;
  K -= 2;

  for (int i = s+1; i < N && K > 0; i++) {
    int chg = 0;
    if (S[i] == 'a') chg++;
    if (T[i] == 'b') chg++;

    ll d = min(K, curr+chg);
    ans += d * (N-i);
    K -= d;
    curr += d;
  }

  cout << ans << endl;

  return 0;
}


#include <bits/stdc++.h>
typedef long long ll;
#define repVector(v)  for( auto it = v.begin(); it != v.last(); it++ )
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define FOR(i,a,b) for( ll i = (ll)(a); i <= (ll)(b); i++ )
#define ROF(i,a,b) for( ll i = (ll)(a); i >= (ll)(b); i-- )
#define debug(x) cerr << "[DEBUG] " << #x << " = " << x << endl;
#define matrix vector< vector<ll> >
#define F first
#define S second
#define mp make_pair
#define INPFILE freopen("input.in","r",stdin)
#define OUTFILE freopen("output.out","w",stdout)
#define BOOST ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

ll n, k;
string s, t;

vector<string> v;

void fun(ll cur, string s) {
  if(cur == 0) {
    v.pb(s);
    return;
  }
  fun(cur - 1, s + "a");
  fun(cur - 1, s + "b");
}

int main() {

  ll ans = 0;
  cin >> n >> k;
  cin >> s >> t;

  while(!s.empty() && !t.empty() && *s.begin() == *t.begin()) {
    n--;
    s.erase(s.begin());
    t.erase(t.begin());
    ans++;
  }

  if(s > t) swap(s, t);

  debug(s); debug(t);

  ll has = 1;

  if(n - 1 > 0) ans += 2;

  has = 1;
  FOR(i,1,n-1) {
    if(s[i] == 'a') {
      FOR(j,i,n-1) {
         if(has >= k) {
          ans += k;
        } else {
          has *= 2;
          ans += min(has, k);
        }
      }
      break;
    }
    ans++;
  }

  debug(ans);

  has = 1;
  FOR(i,1,n-1) {
    if(t[i] == 'b') {
      FOR(j,i,n-1) {
         if(has >= k) {
          ans += k;
        } else {
          has *= 2;
          ans += min(has, k);
        }
      }
      break;
    }
    ans++;
  }

  cout << ans;
}


#include <bits/stdc++.h>
typedef long long ll;
#define repVector(v)  for( auto it = v.begin(); it != v.last(); it++ )
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define FOR(i,a,b) for( ll i = (ll)(a); i <= (ll)(b); i++ )
#define ROF(i,a,b) for( ll i = (ll)(a); i >= (ll)(b); i-- )
#define debug(x) cerr << "[DEBUG] " << #x << " = " << x << endl;
#define matrix vector< vector<ll> >
#define F first
#define S second
#define mp make_pair
#define INPFILE freopen("input.in","r",stdin)
#define OUTFILE freopen("output.out","w",stdout)
#define BOOST ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

ll n, k;
string s, t;

vector<string> v;

void fun(ll cur, string s) {
  if(cur == 0) {
    v.pb(s);
    return;
  }
  fun(cur - 1, s + "a");
  fun(cur - 1, s + "b");
}

int main() {
  ll ans = 0;
  cin >> n >> k;
  cin >> s >> t;

  ll ranks = 0, rankt = 0;

  ll ptr = 0;
  while(ptr < n && s[ptr] == t[ptr]) {
    ans++; ptr++;
  }

  FOR(i,ptr,n-1) {
    if(ranks < LLONG_MAX/2 && rankt < LLONG_MAX/2) {
      ranks <<= 1;
      rankt <<= 1;

      if(s[i] == 'b') ranks++;
      if(t[i] == 'b') rankt++;

      //cerr << s[i] << ' ' << t[i] << ' ' << ranks << ' ' << rankt << '\n';
    }
    ans += min(k, (rankt - ranks + 1));
  }

  cout << ans;
}


#include <bits/stdc++.h>
typedef long long ll;
#define repVector(v)  for( auto it = v.begin(); it != v.last(); it++ )
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define FOR(i,a,b) for( ll i = (ll)(a); i <= (ll)(b); i++ )
#define ROF(i,a,b) for( ll i = (ll)(a); i >= (ll)(b); i-- )
#define debug(x) cerr << "[DEBUG] " << #x << " = " << x << endl;
#define matrix vector< vector<ll> >
#define F first
#define S second
#define mp make_pair
#define INPFILE freopen("input.in","r",stdin)
#define OUTFILE freopen("output.out","w",stdout)
#define BOOST ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

ll n, k;
string s, t;

vector<string> v;

void fun(ll cur, string s) {
  if(cur == 0) {
    v.pb(s);
    return;
  }
  fun(cur - 1, s + "a");
  fun(cur - 1, s + "b");
}

int main() {
  ll ans = 0;
  cin >> n >> k;
  cin >> s >> t;

  ll ranks = 0, rankt = 0;

  FOR(i,0,n-1) {
    if(ranks < LLONG_MAX/4 && rankt < LLONG_MAX/4) {
      ranks <<= 1;
      rankt <<= 1;

      if(s[i] == 'b') ranks++;
      if(t[i] == 'b') rankt++;
    }
    ans += min(k, (rankt - ranks + 1));
  }

  cout << ans;
}


#include <bits/stdc++.h>
typedef long long ll;
#define repVector(v)  for( auto it = v.begin(); it != v.last(); it++ )
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define FOR(i,a,b) for( ll i = (ll)(a); i <= (ll)(b); i++ )
#define ROF(i,a,b) for( ll i = (ll)(a); i >= (ll)(b); i-- )
#define debug(x) cerr << "[DEBUG] " << #x << " = " << x << endl;
#define matrix vector< vector<ll> >
#define F first
#define S second
#define mp make_pair
#define INPFILE freopen("input.in","r",stdin)
#define OUTFILE freopen("output.out","w",stdout)
#define BOOST ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

ll n, k;
string s, t;

vector<string> v;

void fun(ll cur, string s) {
  if(cur == 0) {
    v.pb(s);
    return;
  }
  fun(cur - 1, s + "a");
  fun(cur - 1, s + "b");
}

int main() {

  ll ans = 0;
  cin >> n >> k;
  cin >> s >> t;

  while(!s.empty() && !t.empty() && *s.begin() == *t.begin()) {
    n--;
    s.erase(s.begin());
    t.erase(t.begin());
    ans++;
  }

  if(s > t) swap(s, t);

  debug(s); debug(t);

  ll has = 1;

  if(n > 0) ans += 2;

  has = 1;
  ll left = k;

  FOR(i,1,n-1) {
    if(s[i] == 'a') {
      FOR(j,i,n-1) {
         if(has >= k) {
          ans += k;
          left = 0;
        } else {
          has *= 2;
          left -= has;
          ans += min(has, k);
        }
      }
      break;
    }
    ans++;
  }

  debug(ans);
  debug(left);

  has = 2;
  FOR(i,1,n-1) {
    if(t[i] == 'b') {
      ans += 2;
      FOR(j,i + 1,n-1) {
         if(has >= left) {
          ans += left;
        } else {
          has *= 2;
          ans += min(has, left);
        }
      }
      break;
    }
    ans++;
  }

  cout << ans;
}


#include <bits/stdc++.h>
typedef long long ll;
#define repVector(v)  for( auto it = v.begin(); it != v.last(); it++ )
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define FOR(i,a,b) for( ll i = (ll)(a); i <= (ll)(b); i++ )
#define ROF(i,a,b) for( ll i = (ll)(a); i >= (ll)(b); i-- )
#define debug(x) cerr << "[DEBUG] " << #x << " = " << x << endl;
#define matrix vector< vector<ll> >
#define F first
#define S second
#define mp make_pair
#define INPFILE freopen("input.in","r",stdin)
#define OUTFILE freopen("output.out","w",stdout)
#define BOOST ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

ll n, k;
string s, t;

vector<string> v;

void fun(ll cur, string s) {
  if(cur == 0) {
    v.pb(s);
    return;
  }
  fun(cur - 1, s + "a");
  fun(cur - 1, s + "b");
}

int main() {
  ll ans = 0;
  cin >> n >> k;
  cin >> s >> t;

  ll ranks = 0, rankt = 0;

  FOR(i,0,n-1) {
    if(rankt - ranks < k) {
      ranks <<= 1;
      rankt <<= 1;

      if(s[i] == 'b') ranks++;
      if(t[i] == 'b') rankt++;
    }
    ans += min(k, (rankt - ranks + 1));
  }

  cout << ans;
}


#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 3e5 + 5;
char a[maxn], b[maxn];

int main() {
	int n;
	ll k;
	scanf("%d%lld", &n, &k);
	scanf("%s", a);
	scanf("%s", b);
	ll ans = 0, now = 1;
	if (k == 1) {
		printf("%d\n", n);
		return 0;
	}
	for (int i = 0; i < n; i++) {
		now *= 2;
		if (a[i] != 'a')now--;
		if (b[i] != 'b')now--;
		now = min(now, k);
		ans += now;
	}
	printf("%lld\n", ans);
}


#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 5e5 + 5;
char a[maxn], b[maxn];

int main() {
	int n;
	ll k;
	scanf("%d%lld", &n, &k);
	scanf("%s", a);
	scanf("%s", b);
	ll ans = 0, now = 1;
	if (k == 1) {
		printf("%d\n", n);
		return 0;
	}
	for (int i = 0; i < n; i++) {
		now *= 2;
		if (a[i] != 'a')now--;
		if (b[i] != 'b')now--;
		now = min(now, k);
		ans += now;
	}
	printf("%lld\n", ans);
}


#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 1e5 + 5;
char a[maxn], b[maxn];

int main() {
	int n;
	ll k;
	scanf("%d%lld", &n, &k);
	scanf("%s", a);
	scanf("%s", b);
	ll ans = 0, now = 1;
	if (k == 1) {
		printf("%d\n", n);
		return 0;
	}
	for (int i = 0; i < n; i++) {
		now *= 2;
		if (a[i] != 'a')now--;
		if (b[i] != 'b')now--;
		now = min(now, k);
		ans += now;
	}
	printf("%lld\n", ans);
}


#include <string.h>
#include <unordered_map>

#include <sstream>
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include <bitset>
#include <algorithm>
#include <iostream>
#include   <stdlib.h>
#include   <time.h>
#include <stack>
#include <queue>
#include <set>

#include <map>
#include <vector>
#include <string>
#include <stdlib.h>

#define ll long long
#define clr(x) memset(x,0,sizeof(x))
#define _clr(x) memset(x,-1,sizeof(x))
#define fr(i,a,b) for(int i = a; i < b; ++i)
#define frr(i,a,b) for(int i = a; i > b; --i)
#define pb push_back
#define sf scanf

#define pf printf
#define mp make_pair

using namespace std;
const int N = 1100000;
int mod = 998244353;

int n,k;
string s,t;

int bfs(){
	vector<pair<int,int> > lt;
	lt.push_back(make_pair(0,3));

	int ans = 0;
	while(lt.size()<k) {
		queue<pair<int,int>> q;
		//printf("lt size %d\n",lt.size());
		int cur = 0;
		for(auto x:lt) {
			q.push(x);
			cur = x.first;
			if(x.first>s.size()) {
				break;
			}
			if(x.first>0)
				ans++;
			//printf("push idx = %d flag = %d\n",x.first, x.second);
		}
		lt.clear();
		if(cur>s.size())break;
		while(!q.empty()) {
			auto x = q.front();
			q.pop();
			if(x.second==3) {
				if(s[x.first]!=t[x.first]) {
					lt.pb(mp(x.first+1,1));
					lt.pb(mp(x.first+1,2));
				}
				else {
					lt.pb(mp(x.first+1,3));
				}
			}
			else if(x.second==1) {
				if(s[x.first]=='a') {
					lt.pb(mp(x.first+1,1));
					lt.pb(mp(x.first+1,0));
				}
				else{
					lt.pb(mp(x.first+1,1));
				}
			}
			else if(x.second==2) {
				if(t[x.first]=='a') {
					lt.pb(mp(x.first+1,2));
				}
				else{
					lt.pb(mp(x.first+1,2));
					lt.pb(mp(x.first+1,0));
				}
			}
			else {
				lt.pb(mp(x.first+1,0));
				lt.pb(mp(x.first+1,0));
			}
		}
	}
	for(int i = 0; i< min(k,(int)lt.size()); ++i) {
		if(lt[i].first==0) {
			ans += n-lt[i].first;
		}
		else{
			ans += n-lt[i].first+1;
		}
	}
	return ans;
}

int main() {
	cin>>n>>k;
	cin>>s>>t;
	cout<<bfs()<<endl;
}


#include <string.h>
#include <unordered_map>

#include <sstream>
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include <bitset>
#include <algorithm>
#include <iostream>
#include   <stdlib.h>
#include   <time.h>
#include <stack>
#include <queue>
#include <set>

#include <map>
#include <vector>
#include <string>
#include <stdlib.h>

#define ll long long
#define clr(x) memset(x,0,sizeof(x))
#define _clr(x) memset(x,-1,sizeof(x))
#define fr(i,a,b) for(int i = a; i < b; ++i)
#define frr(i,a,b) for(int i = a; i > b; --i)
#define pb push_back
#define sf scanf

#define pf printf
#define mp make_pair

using namespace std;
const int N = 1100000;
int mod = 998244353;

int n,k;
string s,t;

int bfs(){
	vector<pair<int,int> > lt;
	lt.push_back(make_pair(0,3));

	int ans = 0;
	while(lt.size()<k) {
		queue<pair<int,int>> q;
		//printf("lt size %d\n",lt.size());
		int cur = 0;
		for(auto x:lt) {
			q.push(x);
			cur = x.first;
			if(x.first>s.size()) {
				break;
			}
			if(x.first>0)
				ans++;
			//printf("push idx = %d flag = %d\n",x.first, x.second);
		}
		lt.clear();
		if(cur>s.size())break;
		while(!q.empty()) {
			auto x = q.front();
			q.pop();
			if(x.second==3) {
				if(s[x.first]!=t[x.first]) {
					lt.pb(mp(x.first+1,1));
					lt.pb(mp(x.first+1,2));
				}
				else {
					lt.pb(mp(x.first+1,3));
				}
			}
			else if(x.second==1) {
				if(s[x.first]=='a') {
					lt.pb(mp(x.first+1,1));
					lt.pb(mp(x.first+1,0));
				}
				else{
					lt.pb(mp(x.first+1,1));
				}
			}
			else if(x.second==2) {
				if(t[x.first]=='a') {
					lt.pb(mp(x.first+1,2));
				}
				else{
					lt.pb(mp(x.first+1,2));
					lt.pb(mp(x.first+1,0));
				}
			}
			else {
				lt.pb(mp(x.first+1,0));
				lt.pb(mp(x.first+1,0));
			}
		}
	}
	for(int i = 0; i< min(k,(int)lt.size()); ++i) {
		ans += n-lt[i].first+1;
	}
	return ans;
}

int main() {
	cin>>n>>k;
	cin>>s>>t;
	cout<<bfs()<<endl;
}


#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <list>

using namespace std;

#define FOR(i,a,b) for(int i=a; i<(int)b; i++)
#define ROF(i,a,b) for(int i=a-1; i>=(int)b; i--)
#define REP(i,a) for(int i=0; i<(int)a; i++)
#define PER(i,a) for(int i=(int)a-1; i>=0; i--)
#define MS(a,i) memset(a,i,sizeof(a))
#define SORT(a) sort(a.begin(), a.end())
#define SZ(a) (int)a.size()
#define oo 0x7f7f7f7f

typedef vector<int> ve;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef pair <int, ii> iii;
typedef long long ll;

int n, a[100003], v[100003];

int main() {
	cin >> n;
	REP(i,n) cin>>a[i];
	int s = 0;
	PER(i,n) {
		if(a[i] > s) {
			v[i] = 1;
			s = a[i] - s;
		}
		else
			s-=a[i];
	}
	int t = 0;
	REP(i,n) {
		t ^= v[i];
		if(t) cout << "+";
		else cout << "-";
	}
	return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int n;
    int a[100010];
    while(cin>>n)
    {
        for(int i=1;i<=n;i++)
        cin>>a[i];
        if(n==1)
        cout<<"+\n";
        else if(n==2)
        cout<<"-+\n";
        else
        for(int i=1;i<n;i++)
        {cout<<"+";
        cout<<"-\n";}
    }
    return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int n;
    int a[100010];
    while(cin>>n)
    {
        for(int i=1;i<=n;i++)
        cin>>a[i];
        if(n==1)
        cout<<"+\n";
        else
        for(int i=1;i<n;i++)
        {cout<<"+";
        cout<<"-\n";}
    }
    return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int n;
    int a[100010];
    while(cin>>n)
    {
        for(int i=1;i<=n;i++)
        cin>>a[i];
        if(n==1)
        cout<<"+\n";
        else if(n==2)
        cout<<"-+\n";
        else
        {for(int i=1;i<n;i++)
        cout<<"+";
        cout<<"-\n";}
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define maxn 100010
int main()
{
    int n;
    int a[maxn];
    int x[maxn];
    int y[maxn];
    while(cin>>n)
    {
        memset(a,0,sizeof(0));
        memset(x,0,sizeof(0));
        memset(y,0,sizeof(0));
        for(int i=1;i<=n;i++)
        cin>>a[i];
        int sum=0;
        for(int i=n;i>=1;i--)
        {
            if(sum>a[i])
            {
                x[i]=-1;
                y[i]=1;
                sum-=a[i];
            }
            else
            {
                x[i]=1;
                y[i]=-1;
                sum=a[i]-sum;
            }
        }
        int s=1;
        for(int i=1;i<=n;i++)
        {
            if(s*x[i]==1)
            cout<<"+";
            else
            cout<<"-";
            s=s*y[i];
        }
        cout<<endl;
    }
    return 0;
}