{"trustable":true,"sections":[{"title":"Description","value":{"format":"MD","content":"**The problem is translated from \u003ca href\u003d\u0027https://sio2.mimuw.edu.pl/c/pa-2020-1/dashboard/\u0027 target\u003d\u0027_blank\u0027\u003ePA 2020\u003c/a\u003e Round 1 \u003ca href\u003d\u0027https://sio2.mimuw.edu.pl/c/pa-2020-1/p/kol/\u0027 target\u003d\u0027_blank\u0027\u003eMixing Colors\u003c/a\u003e**\n\nByteasar is preparing to paint a fence. He has prepared $n$ cans of white paint, which he has arranged in a row, numbered from $1$ to $n$. He wants to use this paint, but he doesn\u0027t want to paint the fence white. He has hired a color expert who has three types of paint: yellow, blue, and red. The expert performs $m$ operations, where the $i$th operation involves adding a certain color to all cans between $l_i$ and $r_i$ (inclusive).\n\nThe final color of the paint depends on the colors added to it. The mixing of colors is done according to the table and illustration below.\n\n| Color | Color |\n| :----------------: | :--: |\n| None | White |\n| Yellow | Yellow |\n| Blue | Blue |\n| Red | Red |\n| Yellow + Blue | Green |\n| Yellow + Red | Orange |\n| Blue + Red | Purple |\n| Yellow + Blue + Red| Brown |\n\n![](CDN_BASE_URL/02023a6a49b3823e0ae12325c441b3a4?v\u003d1719570745)\n\nByteasar wants to paint the fence in a single color. After much thought, he chooses green, because green represents \"Accepted\" which you often see in algorithm competitions. He wants to know how many cans of paint are now green. Please help him count."}},{"title":"Input","value":{"format":"MD","content":"The first line contains two integers $n,m$, representing the number of cans of paint and the number of operations performed by the expert.\n\nThe next $m$ lines each contain three integers $l_i,r_i,k_i$, representing that in the $i$th operation, a color is added to cans between $l_i$ and $r_i$ (inclusive). The added color can be yellow ($k_i\u003d1$), blue ($k_i\u003d2$), or red ($k_i\u003d3$)."}},{"title":"Output","value":{"format":"MD","content":"Output a single integer, representing the number of cans of green paint after all operations."}},{"title":"Sample 1","value":{"format":"MD","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e9 5\n2 8 1\n4 5 2\n6 7 3\n5 6 2\n1 2 2\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}},{"title":"Hint","value":{"format":"MD","content":"#### Explanation for Sample 1\n\nAfter the operations, the colors of the cans are blue, green, yellow, green, green, brown, orange, yellow, and white. Therefore, there are only three cans of green paint.\n\n------------\n\n#### Constraints\n\n**This problem uses bundled test cases**\n\nFor $100\\%$ data, ensure that $1\\le n,m\\le 10^6$, $1\\le l_i\\le r_i\\le n$, $1\\le k_i\\le 3$."}}]}