from collections import* n,x,q=map(int,input().split()) ans=0 for _ in range(q): m=int(input()) f=[*map(int,input().split())] d=Counter() p=0 for i in f: if i==x: p=1 break d[i]+=1 if d[i]>1: p=0.5 ans+=p print(ans)