Codeforces Round 119 (Div. 2)
A
Cut Ribbon
Codeforces
1300
原题
←B →
翻译中…

Polycarpus has a ribbon, its length is $*n*$. He wants to cut the ribbon in a way that fulfils the following two conditions:

翻译中…
  • After the cutting each ribbon piece should have length $*a*$, $*b*$ or $*c*$.
  • After the cutting the number of ribbon pieces should be maximum.
翻译中…

Help Polycarpus and find the number of ribbon pieces after the required cutting.

翻译中…

Input

翻译中…

The first line contains four space-separated integers $*n*$, $*a*$, $*b*$ and $*c*$ $(1 ≤ *n*, *a*, *b*, *c* ≤ 4000)$ — the length of the original ribbon and the acceptable lengths of the ribbon pieces after the cutting, correspondingly. The numbers $*a*$, $*b*$ and $*c*$ can coincide.

翻译中…

Output

翻译中…

Print a single number — the maximum possible number of ribbon pieces. It is guaranteed that at least one correct ribbon cutting exists.

翻译中…

Note

翻译中…

In the first example Polycarpus can cut the ribbon in such way: the first piece has length 2, the second piece has length 3.

翻译中…

In the second example Polycarpus can cut the ribbon in such way: the first piece has length 5, the second piece has length 2.

翻译中…

样例

Input #1
5 5 3 2
Output #1
2
InputCopy OutputCopy
Input #2
7 5 5 2
Output #2
2
InputCopy OutputCopy
题目信息
题号
189A
时间限制
1 s
内存限制
256 MB
标签
暴力
动态规划

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。