import sys input = sys.stdin.readline N,M=map(int,input().split()) CARD=[tuple(map(int,input().split())) for i in range(N*M)] D=dict() for i in range(N*M): D[CARD[i]]=i def calc(L): #print("!",L) ANS=0 count=5 while count>0: #print(L) if L[0]>=count: x=L[0]//count ANS+=x for i in range(len(L)): L[i]-=x*count c=0 while L: if L[0]