{"trustable":false,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n section pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\(\u0027, right: \u0027\\\\)\u0027, display: false},\n {left: \u0027\\\\[\u0027, right: \u0027\\\\]\u0027, display: true}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"Problem Statement","value":{"format":"PLAIN","content":"\nMichael Scofield wants to set free his innocent brother, Lincon Burrow who was caught on a false set up and so they have to break from the Fox River prison.\n\nHe needs some keys to open some doors. But the problem is he cannot carry more all keys as the cops would be suspicious. That\u0027s why, he have to choose the master keys to open all the doors.\n\nThey have N keys, and there are M doors.\n\nThey can pass the i-th door if they have one of the following keys: the Li-th, (Li+1)-th, ..., and Ri-th Keys.(any key in range L to R) \n\nHelp Michael to find out how many of the keys allow them to pass all the doors alone?\n\n\n "}},{"title":"Constraints","value":{"format":"PLAIN","content":"All values in input are integers.\n1≤N≤10^5\n1≤M≤10^5\n1≤Li≤Ri≤N"}},{"title":"Input","value":{"format":"PLAIN","content":"Input is given from Standard Input in the following format:\nN M\nL1 R1\nL2 R2\n⋮\nLM RM\n "}},{"title":"Output","value":{"format":"PLAIN","content":"\nPrint the number of keys that allow us to pass all the doors alone."}},{"title":"Sample Input 1","value":{"format":"PLAIN","content":"4 2\n1 3\n2 4\n"}},{"title":"Sample Output 1","value":{"format":"PLAIN","content":"2\nTwo ID cards allow us to pass all the gates alone, as follows:\n \n i. The first ID card does not allow us to pass the second gate.\n ii. The second ID card allows us to pass all the gates.\n iii.The third ID card allows us to pass all the gates.\n iv. The fourth ID card does not allow us to pass the first gate."}},{"title":"Sample Input 2","value":{"format":"PLAIN","content":"10 3\n3 6\n5 7\n6 9"}},{"title":"Sample Output 2","value":{"format":"PLAIN","content":"1\n \nonly 6th key opens all the doors."}},{"title":"Sample Input 3","value":{"format":"PLAIN","content":"100000 1\n1 100000\n"}},{"title":"Sample Output 3","value":{"format":"PLAIN","content":"100000\n"}}]}