ARC#006 A - 宝くじ
def r(): return map(int,raw_input().split()) E=r() B=input() L=r() t=len([x for x in L if x in E]) if t==6: print 1 elif t==5 and B in L: print 2 elif t==5: print 3 elif t==4: print 4 elif t==3: print 5 else: print 0
def r(): return map(int,raw_input().split()) E=r() B=input() L=r() t=len([x for x in L if x in E]) if t==6: print 1 elif t==5 and B in L: print 2 elif t==5: print 3 elif t==4: print 4 elif t==3: print 5 else: print 0