{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eTheater stage is a rectangular field of size \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003en\u003c/i\u003e × \u003ci\u003em\u003c/i\u003e\u003c/span\u003e. The director gave you the stage\u0027s plan which actors will follow. For each cell it is stated in the plan if there would be an actor in this cell or not.\u003c/p\u003e\u003cp\u003eYou are to place a spotlight on the stage in some \u003cspan class\u003d\"tex-font-style-it\"\u003egood\u003c/span\u003e position. The spotlight will project light in one of the four directions (if you look at the stage from above)\u0026nbsp;— left, right, up or down. Thus, the spotlight\u0027s position is a cell it is placed to and a direction it shines.\u003c/p\u003e\u003cp\u003eA position is \u003cspan class\u003d\"tex-font-style-it\"\u003egood\u003c/span\u003e if two conditions hold: \u003c/p\u003e\u003cul\u003e \u003cli\u003e there is no actor in the cell the spotlight is placed to; \u003c/li\u003e\u003cli\u003e there is at least one actor in the direction the spotlight projects. \u003c/li\u003e\u003c/ul\u003e\u003cp\u003eCount the number of \u003cspan class\u003d\"tex-font-style-it\"\u003egood\u003c/span\u003e positions for placing the spotlight. Two positions of spotlight are considered to be different if the location cells or projection direction differ.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line contains two positive integers \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003en\u003c/i\u003e\u003c/span\u003e and \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003em\u003c/i\u003e\u003c/span\u003e (\u003cspan class\u003d\"tex-span\"\u003e1 ≤ \u003ci\u003en\u003c/i\u003e, \u003ci\u003em\u003c/i\u003e ≤ 1000\u003c/span\u003e)\u0026nbsp;— the number of rows and the number of columns in the plan.\u003c/p\u003e\u003cp\u003eThe next \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003en\u003c/i\u003e\u003c/span\u003e lines contain \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003em\u003c/i\u003e\u003c/span\u003e integers, \u003cspan class\u003d\"tex-span\"\u003e0\u003c/span\u003e or \u003cspan class\u003d\"tex-span\"\u003e1\u003c/span\u003e each\u0026nbsp;— the description of the plan. Integer \u003cspan class\u003d\"tex-span\"\u003e1\u003c/span\u003e, means there will be an actor in the corresponding cell, while \u003cspan class\u003d\"tex-span\"\u003e0\u003c/span\u003e means the cell will remain empty. It is guaranteed that there is at least one actor in the plan.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003ePrint one integer\u0026nbsp;— the number of \u003cspan class\u003d\"tex-font-style-it\"\u003egood\u003c/span\u003e positions for placing the spotlight.\u003c/p\u003e"}},{"title":"Examples","value":{"format":"HTML","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\u003e2 4\n0 1 0 0\n1 0 1 0\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e9\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"","value":{"format":"HTML","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\u003e4 4\n0 0 0 0\n1 0 0 1\n0 1 1 0\n0 1 0 0\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e20\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003eIn the first example the following positions are \u003cspan class\u003d\"tex-font-style-it\"\u003egood\u003c/span\u003e:\u003c/p\u003e\u003col\u003e \u003cli\u003e the (1, 1) cell and right direction; \u003c/li\u003e\u003cli\u003e the (1, 1) cell and down direction; \u003c/li\u003e\u003cli\u003e the (1, 3) cell and left direction; \u003c/li\u003e\u003cli\u003e the (1, 3) cell and down direction; \u003c/li\u003e\u003cli\u003e the (1, 4) cell and left direction; \u003c/li\u003e\u003cli\u003e the (2, 2) cell and left direction; \u003c/li\u003e\u003cli\u003e the (2, 2) cell and up direction; \u003c/li\u003e\u003cli\u003e the (2, 2) and right direction; \u003c/li\u003e\u003cli\u003e the (2, 4) cell and left direction. \u003c/li\u003e\u003c/ol\u003e\u003cp\u003eTherefore, there are \u003cspan class\u003d\"tex-span\"\u003e9\u003c/span\u003e \u003cspan class\u003d\"tex-font-style-it\"\u003egood\u003c/span\u003e positions in this example.\u003c/p\u003e"}}]}