import sys
from collections import Counter


def sign(x):
    return (x > 0) - (x < 0)


def main():
    lines = [
        [int(c) for p in line.split(" -> ") for c in p.split(",")]
        for line in sys.stdin
    ]

    for diagonal in [False, True]:
        grid = Counter()

        for x1, y1, x2, y2 in lines:
            if diagonal or x1 == x2 or y1 == y2:
                x = x1
                y = y1

                grid[x, y] += 1

                while (x, y) != (x2, y2):
                    x += sign(x2 - x1)
                    y += sign(y2 - y1)

                    grid[x, y] += 1

        print(sum(v >= 2 for v in grid.values()))


if __name__ == "__main__":
    main()
