PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#QHD0000032. Cắt ruy băng (Cut Ribbon)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Cắt ruy băng (Cut Ribbon)

Cut Ribbon

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

You have a ribbon of length nn. Cut it completely into smaller pieces, each of which must have length exactly one of aa, bb, or cc.

A length may be used repeatedly, and you need not use all three lengths. The lengths of the pieces must sum to exactly nn, with no leftover ribbon. At least one valid cutting is guaranteed.

Find the maximum possible number of pieces.

Input

One line contains nn, aa, bb, and cc: the ribbon length and the three allowed segment lengths.

Output

Print the maximum number of ribbon segments.

Subtasks

  • Subtask 1 (20 points): 1≤n≤401\le n\le 40; 1≤a≤40001\le a\le 4000; 1≤b≤40001\le b\le 4000; 1≤c≤40001\le c\le 4000; At least one valid cutting is guaranteed.
  • Subtask 2 (30 points): 1≤n≤10001\le n\le 1000; 1≤a≤40001\le a\le 4000; 1≤b≤40001\le b\le 4000; 1≤c≤40001\le c\le 4000; At least one valid cutting is guaranteed.
  • Subtask 3 (50 points): 1≤n≤40001\le n\le 4000; 1≤a≤40001\le a\le 4000; 1≤b≤40001\le b\le 4000; 1≤c≤40001\le c\le 4000; At least one valid cutting is guaranteed.

Examples

Input

5 5 3 2

Output

2

Explanation

Cut the ribbon of length 55 into segments of lengths 33 and 22. Three segments are impossible because each would have length at least 22, requiring total length at least 66. The answer is 22.