{"raw_statement":[{"iden":"statement","content":"Byung is playing a game on her infinite checkerboard. The goal of the game is to move from a starting position (rs, cs) to a target position (rt, ct) using *exactly* x moves, where x is determined by a roll of a N-sided dice.\n\nA move consists in going from a square on the checkerboard to one of its four neighbors - up, down, left or right. \n\nHer dice is unbiased, meaning that every number from 1 to N has the same probability of being rolled.\n\nShe's interested in knowing what's the number of different rolls that allow her to move to the target position in the last move. She can move to the same square more than once if she needs to. Can you help her?\n\nThe input is composed by a single line containing 5 integers N (1 ≤ N ≤ 109), rs, cs, rt and ct ( - 109 ≤ rs, cs, rt, ct ≤ 109) indicating respectively the number of sides of the dice, the coordinates of the starting position and the coordinates of the target position.\n\nAn integer number indicating the number of outcomes that she'll get a good roll.\n\n"},{"iden":"input","content":"The input is composed by a single line containing 5 integers N (1 ≤ N ≤ 109), rs, cs, rt and ct ( - 109 ≤ rs, cs, rt, ct ≤ 109) indicating respectively the number of sides of the dice, the coordinates of the starting position and the coordinates of the target position."},{"iden":"output","content":"An integer number indicating the number of outcomes that she'll get a good roll."},{"iden":"examples","content":"Input5 1 1 2 3Output2Input500 -100 -100 100 100Output51"}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ N \\in \\mathbb{Z}^+ $ be the number of points.  \nLet $ P = \\{ (x_i, y_i, p_i) \\mid i \\in \\{1, \\dots, N\\} \\} $ be the set of points, where:  \n- $ (x_i, y_i) \\in \\mathbb{R}^2 $ is the geographical position,  \n- $ p_i \\in \\{ \\text{PSD}, \\text{PS} \\} $ is the political preference.  \n\nLet $ R_1, R_2 \\subseteq \\mathbb{R}^2 $ be axis-aligned rectangles such that $ R_1 \\cap R_2 = \\emptyset $.  \n\n**Constraints**  \n1. $ R_1 $ and $ R_2 $ are axis-aligned rectangles (closed sets, including boundaries).  \n2. $ R_1 \\cap R_2 = \\emptyset $.  \n\n**Objective**  \nMaximize the total weighted count:  \n$$\n\\max_{R_1, R_2} \\left( \\sum_{\\substack{(x_i, y_i, p_i) \\in P \\\\ (x_i, y_i) \\in R_1 \\\\ p_i = \\text{PSD}}} 1 + \\sum_{\\substack{(x_i, y_i, p_i) \\in P \\\\ (x_i, y_i) \\in R_2 \\\\ p_i = \\text{PS}}} 1 \\right)\n$$","simple_statement":"Find two non-overlapping axis-aligned rectangles such that the sum of PSD voters in one rectangle and PS voters in the other is maximized.","has_page_source":false}