//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <algorithm>
#include <array>
#include <cassert>
//#include <chrono>
#include <cmath>
//#include <cstring>
//#include <functional>
//#include <iomanip>
#include <iostream>
#include <map>
//#include <numeric>
//#include <queue>
//#include <random>
#include <set>
#include <vector>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp> 
//using namespace __gnu_pbds; 
#define int long long 
#define ll int
#define all(a) a.begin(),a.end()    
#define rev(a) a.rbegin(),a.rend()    
//typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; //less_equal for multiset
#define ar array
#define pb push_back
#define fi(a,b) for(int i=a;i<(b);i++)
#define fj(a,b) for(int j=a;j<(b);j++)
#define fk(a,b) for(int k=a;k<(b);k++)
const double pi=acosl(-1);



void solve()
{
    int n,k;
    cin>>n>>k;
    vector<pair<int,int>> a(n);
    vector<int> c(n);
    fi(0,n)
    {
        cin>>a[i].first>>a[i].second>>c[i];
    }
    vector<pair<int,int>> temp;
    fi(0,n)
    {
        temp.pb({a[i].first,(i+1)});
        temp.pb({a[i].second+1,-(i+1)});
    }
    sort(all(temp));
    int m=temp.size();
    // int i=0;
    // int count=0;
    int ans=0;
    multiset<int> s;
    int index=abs(temp[0].second)-1;
    int cost=c[index];
    s.insert(index);
    int i=1;
    // for(auto x:temp)
    // {
    //     cout<<x.first<<' ';
    // }
    // cout<<'\n';
    // for(auto x:temp)
    // {
    //     cout<<x.second<<' ';
    // }
    // cout<<'\n';
    while(i<m)
    {
        // cout<<i<<' '<<cost<<'\n';
        index=abs(temp[i].second)-1;
        if(temp[i].second<0)
        {
            int diff=temp[i].first-temp[i-1].first;
            ans+=diff*min(k,cost);
            int here=temp[i].first;
            int prev=i;
            while(i<n&&temp[i].first==here&&temp[i].second<0)
            {
                cost-=c[abs(temp[i].second)-1];
                i++;
            }
            if(i==prev)
            {
                cost-=c[abs(temp[i].second)-1];
                i++;
            }
        }
        else
        {
            int diff=temp[i].first-temp[i-1].first;
            ans+=diff*min(k,cost);
            cost+=c[index];
            i++;
        }
    }
    cout<<ans<<'\n';
    
}

signed main()
{
    FAST;
    int tt=1;
    //cin>>tt;    
    while(tt--)
    {
        solve();
    }    
}










//int dx[] = {+1,-1,+0,+0,-1,-1,+1,+1}; // Eight Directions
//int dy[] = {+0,+0,+1,-1,+1,-1,-1,+1}; // Eight Directions
//int dx[]= {-2,-2,-1,1,-1,1,2,2}; // Knight moves
//int dy[]= {1,-1,-2,-2,2,2,-1,1}; // Knight moves
// For (a^b)%mod, where b is large, replace b by b%(mod-1)..{because we solve this by introducing log ..do same for general cases}
// a+b = (a|b)+(a&b)
// a+b = 2*(a&b)+(a^b)

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

int main(){
	int64_t N, X;
	cin >> N >> X;
	string S;
	cin >> S; 

	int64_t ans = X;
	for(int i=0;i<N;i++){
		if(S.at(i)=='x' && ans>0){
			ans--;
		}else if(S.at(i) == 'o'){
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}