#include<iostream> #include<algorithm> using std::cin; using std::cout; using std::cerr; constint N = 2000005; int l[N], r[N], L, R, n, m; intmain(){ cin >> n >> m; for (int i = 0; i < n; ++i) cin >> l[i] >> r[i]; longlong ans = 0; for (int i = 0; i < m; ++i){ cin >> L >> R; ans += (std::upper_bound(l, l+n, R) - l) - (std::lower_bound(r, r+n, L) - r); } cout << ans; return0; }