n,m=map(int,input().split()) SET=set(range(1,n+1)) FROM=dict() for i in range(m): g,r=map(int,input().split()) SET.remove(g) H=set(map(int,input().split())) FROM[g]=H while SET: flag=-1 for g in FROM: if FROM[g]<=SET: flag=g break if flag==-1: break else: SET.add(g) del FROM[g] print(len(SET))