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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  long long C;
  cin >> n >> C;
  vector<pair<int, int>> v;
  for (int i = 0; i < n; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    v.emplace_back(a, c);
    v.emplace_back(b + 1, -c);
  }
  sort(v.begin(), v.end());
  n <<= 1;
  long long ans = 0, cur = 0;
  for (int i = 0; i < n; ++i) {
    cur += v[i].second;
    int j = i;
    while (j + 1 < n && v[j].first == v[j + 1].first) {
      ++j;
      cur += v[j].second;
    }
    if (j + 1 < n) {
      long long len = v[j + 1].first - v[i].first;
      ans += len * min(C, cur);
    }
    i = j ;
  }
  cout << ans << "\n";
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
namespace Flandre_Scarlet
{
    #define mod 1145141919
	#define F(i,l,r) for(int i=l;i<=r;++i)
	#define D(i,r,l) for(int i=r;i>=l;--i)
	#define Fs(i,l,r,c) for(int i=l;i<=r;c)
	#define Ds(i,r,l,c) for(int i=r;i>=l;c)
	#define MEM(x,a) memset(x,a,sizeof(x))
	#define FK(x) MEM(x,0)
	#define Tra(i,u) for(int i=G.st(u),v=G.to(i);~i;i=G.nx(i),v=G.to(i))
	#define p_b push_back
	#define sz(a) ((int)a.size())
	#define all(a) a.begin(),a.end()
	#define iter(a,p) (a.begin()+p)
	#define PUT(a,n) F(i,1,n) printf("%d ",a[i]); puts("");
	int I() {char c=getchar(); int x=0; int f=1; while(c<'0' or c>'9') f=(c=='-')?-1:1,c=getchar(); while(c>='0' and c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar(); return ((f==1)?x:-x);}
	template <typename T> void Rd(T& arg){arg=I();}
	template <typename T,typename...Types> void Rd(T& arg,Types&...args){arg=I(); Rd(args...);}
	void RA(int *p,int n) {F(i,1,n) *p=I(),++p;}
	char a[10];
    void Input()
    {
        scanf("%s",a);
    }
    int n=4; int C[15][15];
    int must,may;
    int f[15];
    int qpow(int a,int b,int m=mod) {int r=1; while(b) {if (b&1) r=r*a%m; a=a*a%m,b>>=1;} return r;}
    void Sakuya()
    {
        C[0][0]=1;
        F(i,1,10)
        {
            C[i][0]=1;
            F(j,1,i)
            {
                C[i][j]=C[i-1][j]+C[i-1][j-1];
            }
        } 
        
        must=may=0;
        F(i,0,9)
        {
            if (a[i]=='o') ++must;
            if (a[i]=='?') ++may;
        }
        f[0]=qpow(may,n);
        F(i,1,must)
        {
            f[i]=qpow(may+i,n);
            F(j,0,i-1) f[i]-=C[i][j]*f[j];
        }
        printf("%d\n",f[must]);
    }
    void IsMyWife()
    {
        Input();
        Sakuya();
    }
}
#undef int //long long
int main()
{
    Flandre_Scarlet::IsMyWife();
    getchar();
    return 0;
}