*A,G=map(int,input().split()) b=1 x=500 i=0 for a in A: for _ in'_'*a:b|=b<>G&1::2])