I=lambda:input().split();n,q=map(int,I());C={} for _ in'.'*q:c,v=I();C[c]=int(v) m=max(C.values()) if n-m