def ccw(u, v, w):
a1, a2 = v[0] - u[0], v[1] - u[1]
b1, b2 = w[0] - v[0], w[1] - v[1]
return a1*b2 - a2*b1
x1, y1, x2, y2 = map(int, input().split())
x3, y3, x4, y4 = map(int, input().split())
d1 = (x1, y1)
d2 = (x2, y2)
d3 = (x3, y3)
d4 = (x4, y4)
cri1 = ccw(d1, d2, d3)*ccw(d1, d2, d4)
cri2 = ccw(d3, d4, d1)*ccw(d3, d4, d2)
if ccw(d1, d2, d3) == 0 and ccw(d1, d2, d4) == 0:
c1 = max(d1[0], d2[0]) < min(d3[0], d4[0])
c2 = max(d3[0], d4[0]) < min(d1[0], d2[0])
c3 = max(d1[1], d2[1]) < min(d3[1], d4[1])
c4 = max(d3[1], d4[1]) < min(d1[1], d2[1])
print(0 if c1 or c2 or c3 or c4 else 1)
else:
print(
0 if cri1
> 0 or cri2
> 0 else 1)
cs