#include using namespace std; struct Range { int from, to; bool contains(Range &other) { return this->from <= other.from && other.to <= this->to; } bool contains(int n) { return this->from <= n && n <= this->to; } bool overlaps(Range &other) { return this->contains(other.from) || this->contains(other.to) || other.contains(this->from) || other.contains(this->to); } }; int main() { Range a, b; int total1 = 0; int total2 = 0; while (scanf("%d-%d,%d-%d ", &a.from, &a.to, &b.from, &b.to) == 4) { if (a.contains(b) || b.contains(a)) total1++; if (a.overlaps(b)) total2++; } printf("%d\n", total1); printf("%d\n", total2); }