#!/usr/bin/env python3 import sys import pdb from collections import defaultdict grid = defaultdict(lambda: defaultdict(int)) def bigrange(a, b): if a > b: return range(b, a + 1) else: return range(a, b + 1) for l in sys.stdin: a, arrow, b = l.split() x1, y1 = [int(x) for x in a.split(',')] x2, y2 = [int(x) for x in b.split(',')] if x1 == x2: for y in bigrange(y1, y2): grid[x1][y] += 1 elif y1 == y2: for x in bigrange(x1, x2): grid[x][y1] += 1 count = 0 for x in grid.keys(): for y in grid[x].keys(): if grid[x][y] > 1: count += 1 print(count)