#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <cstdio>

using namespace std;

int main(){
	int a[12];
	while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d"
				,&a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8],&a[9],&a[10],&a[11]) != EOF){

		int ans = 0;	
		double t = 0, d = 0;
		int sum = 0;
		for(int i = 0;i < 10;i++){
			sum += a[i];
		}
		t = (double)sum / (a[10]+a[11]);
		d = (double)a[10] * t;
		sum = 0;
		for(int i = 0;i < 10;i++){
			sum += a[i];
			if(sum >= d){
				ans = i + 1;
				break;
			}
		}
		cout << ans << endl;
	}

	return 0;
}
#include <algorithm>
#include <cmath>
#include <iostream>

#define MAX_N 100000

using namespace std;

struct Test
{
    long long score, upper, lower;

    long long sum();
};

Test tests[MAX_N];
long long cum[MAX_N + 1];
long long N, X;
long long aokiScore;

bool cmp( Test u, Test v ) { return u.sum() > v.sum(); }

long long Test::sum() { return upper * ( X - score ) + lower * score; }

bool isok( long long k )
{
    long long q = k / X;
    long long r = k % X;

    if ( q == N ) return true;

    long long total = cum[q];

    for ( int i = 0; i < N; ++i )
    {
        long long tmp = total;

        if ( i < q )
        {
            tmp -= tests[i].sum();
            tmp += tests[q].sum();
        }

        tmp += min( r, tests[i].score ) * tests[i].lower;
        tmp += max( 0LL, r - tests[i].score ) * tests[i].upper;

        if ( tmp >= aokiScore ) return true;
    }

    return false;
}

int main()
{
    N = 0;
    aokiScore = 0;
    cin >> N >> X;

    for ( int i = 0; i < N; ++i )
    {
        cin >> tests[i].score >> tests[i].lower >> tests[i].upper;
        aokiScore += tests[i].score * tests[i].lower;
    }

    sort( tests, tests + N, cmp );

    for ( int i = 0; i < N; ++i ) cum[i + 1] = cum[i] + tests[i].sum();

    long long l = 0;
    long long r = N * X;

    while ( l < r )
    {
        long long mid = ( l + r ) / 2;

        if ( isok( mid ) )
            r = mid;
        else
            l = mid + 1;
    }

    cout << l << endl;

    return 0;
}
