#include using namespace std; using ll = long long; const ll MOD = 1000000007; using P = pair; #define rep(i, n) for(int i = 0; i < n; i++) #define all(x) (x).begin(),(x).end() int main(){ int n,q; cin >> n >> q; vector x(n,false); int ans = 0; rep(i,q){ int l,r; cin >> l >> r; l--; r--; for(int j=l;j<=r;j++){ ans -= x[j]; x[j] = x[j] - 1; ans += x[j]; } cout << ans << endl; } return 0; }