#include using namespace std; bool range_contains(int a1, int a2, int b1, int b2) { return a1 <= b1 && b2 <= a2; } bool range_in(int a1, int a2, int v) { return a1 <= v && v <= a2; } bool range_overlap(int a1, int a2, int b1, int b2) { return range_in(a1, a2, b1) || range_in(a1, a2, b2) || range_in(b1, b2, a1) || range_in(b1, b2, a2); } int main() { int a1, a2, b1, b2; int total1 = 0; int total2 = 0; while (scanf("%d-%d,%d-%d ", &a1, &a2, &b1, &b2) == 4) { if (range_contains(a1, a2, b1, b2) || range_contains(b1, b2, a1, a2)) total1++; if (range_overlap(a1, a2, b1, b2)) total2++; } printf("%d\n", total1); printf("%d\n", total2); }