#include #include int grid[1000][1000] = {0}; void draw(int x1, int y1, int x2, int y2) { int r = x1; int c = y1; int rstep = x1 == x2 ? 0 : (x1 < x2 ? 1 : -1); int cstep = y1 == y2 ? 0 : (y1 < y2 ? 1 : -1); while (r != x2 || c != y2) { grid[r][c]++; r += rstep; c += cstep; } /* loop stops before marking last point! */ grid[x2][y2]++; } int main(void) { int x1, y1, x2, y2; while (scanf("%d,%d -> %d,%d\n", &x1, &y1, &x2, &y2) != EOF) { draw(x1, y1, x2, y2); } int count = 0; for (int r = 0; r < 1000; r++) { for (int c = 0; c < 1000; c++) { if (grid[r][c] > 1) { count++; } } } printf("%d\n", count); return 0; }