{"raw_statement":[{"iden":"statement","content":"Monocarp decided to buy ball ornaments to decorate his Christmas tree. There are only three colors of ornaments in the shop nearby: red, yellow, and blue. Fortunately, there are infinitely many ornaments of each color.\n\nOne red ornament costs $r$ burles, one yellow ornament — $y$ burles, and one blue ornament — $b$ burles.\n\nMonocarp has $n$ burles and would like to buy as many ornaments as possible. But he considers Christmas tree to be beautifully decorated only if the numbers of ornaments of each color differ by not more than one. More formally, if Monocarp will buy $c n t_r$ red ornaments, $c n t_y$ yellow ornaments, and $c n t_b$ blue ornaments then the following conditions should be fulfilled: $| c n t_r -c n t_y | <= 1$, $| c n t_r -c n t_b | <= 1$, $| c n t_y -c n t_b | <= 1$.\n\nCalculate the maximum possible total number of ornaments Monocarp can buy in such a way that the numbers of ornaments of each color differ by not more than one.\n\nThe first line contains one integer $n$ ($1 <= n <= 1000$) — the amount of money Monokarp has.\n\nThe second line contains one integer $r$ ($1 <= r <= n$) — the cost of one red ornament.\n\nThe third line contains one integer $y$ ($1 <= y <= n$) — the cost of one yellow ornament.\n\nThe fourth line contains one integer $b$ ($1 <= b <= n$) — the cost of one blue ornament.\n\nPrint the maximum possible total number of ornaments Monocarp can buy in such a way that the numbers of ornaments of each color differ by not more than one.\n\nIn the first sample, Monocarp can buy two ornaments of each color and will spend all $12$ burles he has. In total, he can buy at most $6$ ornaments.\n\nIn the second sample, Monocarp can buy $3$ red ornaments, $2$ yellow ornaments, and $2$ blue ornaments and will spend $3 dot.op 1 + 2 dot.op 4 + 2 dot.op 7 = 25$ burles. In total Monocarp can buy at most $7$ ornaments. Monocarp still has $1$ burle left, but he won't buy extra red ornament, since it will break the beautiful decoration of the Christmas tree described in the statement.\n\nIn the third sample, Monocarp can buy $1$ red ornament, $2$ yellow ornaments, and $2$ blue ornaments and will spend $1 dot.op 4 + 2 dot.op 2 + 2 dot.op 3 = 14$ burles. In total, he can buy at most $5$ ornaments.\n\n"},{"iden":"input","content":"The first line contains one integer $n$ ($1 <= n <= 1000$) — the amount of money Monokarp has.The second line contains one integer $r$ ($1 <= r <= n$) — the cost of one red ornament.The third line contains one integer $y$ ($1 <= y <= n$) — the cost of one yellow ornament.The fourth line contains one integer $b$ ($1 <= b <= n$) — the cost of one blue ornament."},{"iden":"output","content":"Print the maximum possible total number of ornaments Monocarp can buy in such a way that the numbers of ornaments of each color differ by not more than one."},{"iden":"examples","content":"Input12\n2\n2\n2\nOutput6\nInput26\n1\n4\n7\nOutput7\nInput17\n4\n2\n3\nOutput5\nInput100\n100\n100\n100\nOutput1\n"},{"iden":"note","content":"In the first sample, Monocarp can buy two ornaments of each color and will spend all $12$ burles he has. In total, he can buy at most $6$ ornaments.In the second sample, Monocarp can buy $3$ red ornaments, $2$ yellow ornaments, and $2$ blue ornaments and will spend $3 dot.op 1 + 2 dot.op 4 + 2 dot.op 7 = 25$ burles. In total Monocarp can buy at most $7$ ornaments. Monocarp still has $1$ burle left, but he won't buy extra red ornament, since it will break the beautiful decoration of the Christmas tree described in the statement.In the third sample, Monocarp can buy $1$ red ornament, $2$ yellow ornaments, and $2$ blue ornaments and will spend $1 dot.op 4 + 2 dot.op 2 + 2 dot.op 3 = 14$ burles. In total, he can buy at most $5$ ornaments."}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ n \\in \\mathbb{Z}^+ $ be the budget.  \nLet $ r, y, b \\in \\mathbb{Z}^+ $ be the costs of one red, yellow, and blue ornament, respectively.  \nLet $ c_r, c_y, c_b \\in \\mathbb{Z}_{\\geq 0} $ be the counts of red, yellow, and blue ornaments purchased.\n\n**Constraints**  \n1. $ c_r + c_y + c_b \\leq \\left\\lfloor \\frac{n}{\\min(r, y, b)} \\right\\rfloor $ (budget constraint)  \n2. $ |c_r - c_y| \\leq 1 $, $ |c_r - c_b| \\leq 1 $, $ |c_y - c_b| \\leq 1 $ (balance constraint)  \n3. $ c_r \\cdot r + c_y \\cdot y + c_b \\cdot b \\leq n $ (cost constraint)\n\n**Objective**  \nMaximize $ c_r + c_y + c_b $ subject to the above constraints.","simple_statement":"Monocarp wants to buy as many ornaments as possible with n burles.  \nThere are three colors: red (cost r), yellow (cost y), blue (cost b).  \nHe must buy so that the counts of each color differ by at most 1.  \nFind the maximum total number of ornaments he can buy.","has_page_source":false}