import sys input = sys.stdin.readline from collections import Counter N,X,Q=map(int,input().split()) ANS=0 for tests in range(Q): M=int(input()) L=Counter(map(int,input().split())) if X in L: ANS+=1 else: for c in L: if L[c]>=2: ANS+=0.5 break print(ANS)