#include<bits/stdc++.h>
#define forb(i,a,b) for(ll i=a;i<b;i++)
#define fore(i,a,b) for(ll i=a;i<=b;i++)
#define sortb(a) sort(a.begin(),a.end())
#define sortr(a) sort(a.begin(),a.end(),greater<ll> ())
#define inf LLONG_MAX
typedef long long int ll;
typedef long double ld;
using namespace std;

void solve(){
	ll n,a,x;
	cin>>n>>a;
	x=n;
	ll ct=0;
	while(x>0){
		ct+=(x%10);
		x/=10;
	}
	if(ct<=a){
		cout<<0<<endl;
	}
	else{
		ll i=0,ans=0;
		bool y=true;
		while(ct>a and y){
			if((ct-(n%10))>a){
				ans+=((10-(n%10))*pow(10,i));
				ct-=(n%10);
				n/=10;
				i++;
			}
			else{
				y=false;
			}
		}
		cout<<ans<<endl;
	}
}

int main(){
	ll a,b;
	string s;
	cin>>a>>b>>s;
	forb(i,0,a){
		if(s[i]=='o'){
			b++;
		}
		if(s[i]=='x' and b){
			b--;
		}
	}
	cout<<b<<endl;
	
}

#include"bits/stdc++.h"
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(x) x.begin(),x.end()
#define BACK(x) x.rbegin(),x.rend()
#define MOD 1000000007
#define INF INT_MAX
#define FLOAT_ANS setprecision(30)
#define TORAD(x) (x*acos(-1)/180.0)
#define TODEG(x) (x*180/acos(-1))
#define elif else if

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

template<typename T>
bool chmin(T& a,T b){
	if(a>b){
		a=b;
		return true;
	}
	return false;
}

template<typename T>
bool chmax(T& a,T b){
	if(a<b){
		a=b;
		return true;
	}
	return false;
}

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = (res * (a%mod)) % mod;
        a = ((a%mod) * (a%mod)) % mod;
        n >>= 1;
    }
    return res;
}

// MAIN PROGRAM -------------

int main(){
	ll n,p;
	cin>>n>>p;
	--p;
	ll ans=modpow(p-1,n-1,MOD);
	cout<<(ans*p)%MOD;
}

/*

*/