https://www.acmicpc.net/problem/14697
a,b,c,n=input().split()
a=int(a)
b=int(b)
c=int(c)
n=int(n)
x=0
for i in range(int(n/a)+1):
for j in range(int(n/b)+1):
for k in range(int(n/c)+1):
if a*i+b*j+c*k==n:
x+=1
break
if x==0:
print("0")
else:
print("1")