n, m = map(int, input().split()) d = {} for _ in range(m): g, r = map(int, input().split()) d[g] = set(map(int, input().split())) for s in d.values(): s &= set(d) while d: k = min(d, key=lambda x: len(d[x])) if len(d[k]) > 0: break for s in d.values(): s.discard(k) del d[k] print(n - len(d))