A healthy menu
시간 제한2초메모리 제한2048 MB
각 반에서 각 과일을 좋아하는 학생 수가 주어질 때, 모든 학생이 과일을 하나 이상 좋아하고 각 반에 학생이 최소 한 명 있다는 조건 아래 학교의 최소 학생 수를 구한다.
문제
At the Institute of Creative Programming Competitions (ICPC), all students love fruits! Knowing this, management decided to conduct a large survey about food preferences to help in preparing the annual menu. To make the survey more professional, they hired the company SBC Research Solutions™, an acronym for “Saladas Bem Científicas”, although some say the name is a tribute to a well-known computer science society...
SBC received the following mission: the school has classes and offers different types of fruit. In each class, for each fruit, the number of students who like that fruit was reported.
However, since SBC did not have access to individual student data, nor do they know how many students are in each class, they now need your help! Based only on the survey results (how many students like each fruit in each class), determine the smallest possible number of students the school can have, knowing that the following constraints are satisfied:
- each class has at least one student;
- each student belongs to a single class;
- each student likes at least one fruit;
- the same student can like several fruits.
입력
The first line of input contains two integers and (), the number of fruits and the number of classes, respectively. Each of the following lines contains integers , indicating how many students in class like fruit ( for and ).
출력
Your program should print a single line, containing a single integer, the smallest possible number of students in the school, considering the given constraints.