#include #include using namespace std; int main(int argc, char* argv[]) { int N,M; cin>>N>>M; vector x(N),a(N),b(N); vector xTmp(N); int i; int maxA=0; int maxB=0; int n2Num=0; int n3Num=0; for (i=0;i>x[i]>>a[i]>>b[i]; if (maxA=2){ n2Num++; } if (x[i]>=3){ n3Num++; } } if (n2Num>=M){ cout<=0;sb--){ n2Num=0; n3Num=0; for (i=0;i=sa){ xTmp[i]++; } if (b[i]>=sb){ xTmp[i]++; } if (xTmp[i]>=2){ n2Num++; } if (xTmp[i]>=3){ n3Num++; } } if (n2Num>=M){ if (minN3Num>n3Num){ minN3Num=n3Num; } } } } cout<