#include #include #include using namespace std; #define PLUS 1 #define MINUS 0 typedef pair Interval; typedef pair Pair; int l, r; int n; int sub; bool dir; vector as; set intervals; int main() { scanf("%d", &n); for (int i=0; ifirst; int l = intervals.rbegin()->second.first; int r = intervals.rbegin()->second.second; if (num <= 2) break; intervals.erase(Pair(num, Interval(l, r))); sub += num-2; intervals.insert(Pair(2, Interval(l, r))); } if (n - sub <= 2) { puts("0"); } else { printf("%d\n", n-sub); } }