@staticmethod
def d():
    (sx, sy, gx, gy) = map(int, sys.stdin.readline().split())
    seg1 = ((sx, sy), (gx, gy))
    n = int(sys.stdin.readline().rstrip())
    p1 = np.array(sys.stdin.read().split(), dtype=np.int64).reshape(n, 2).T
    p2 = np.hstack((p1[:, 1:], p1[:, :1]))
    seg2 = (p1, p2)
    print(((np.count_nonzero(GeometryTopology.intersect(seg1, seg2)) // 2) + 1))
@staticmethod
def d():
    (sx, sy, gx, gy) = map(int, sys.stdin.readline().split())
    seg1 = ((sx, sy), (gx, gy))
    n = int(sys.stdin.readline().rstrip())
    p1 = np.array(sys.stdin.read().split(), dtype=np.int64).reshape(n, 2).T
    p2 = np.hstack((p1[:, 1:], p1[:, :1]))
    seg2 = (p1, p2)
    print(((np.count_nonzero(GeometryTopology.intersect(seg1, seg2)) // 2) + 1))