QOJ.ac

QOJ

時間限制: 2.0 s 記憶體限制: 1024 MB 總分: 100 可 Hack ✓

#14403. Custom Banknotes

统计

In the Jagan Kingdom, only 1-yen banknotes have been issued so far. However, due to the increase in the circulation of banknotes, the kingdom has decided to renew its banknote system entirely. The new banknote system is represented by a sequence of positive integers $x = (x_1, x_2, \dots, x_k)$. This means that the new system uses $k$ types of banknotes with denominations of $x_1, x_2, \dots, x_k$ yen. You can decide the number of banknote types $k$ and their values $x_1, x_2, \dots, x_k$ under the following restrictions:

  • $k$ is a positive integer.
  • $1 = x_1 < x_2 < \dots < x_k$.
  • $x_{i+1}$ must be a multiple of $x_i$ ($1 \le i \le k - 1$).

In the Jagan Kingdom, goods are often traded at prices of $a$, $b$, or $c$ yen. Therefore, the inconvenience of the new banknote system is defined as:

(The minimum number of banknotes required to represent $a$ yen) $+$ (The minimum number of banknotes required to represent $b$ yen) $+$ (The minimum number of banknotes required to represent $c$ yen).

Your task is to find the minimum possible value of this inconvenience.

Input

The first line of the input contains three integers: $a$, $b$, and $c$ ($1 \le a < b < c \le 10^8$).

Output

Print one integer: the minimum possible value of inconvenience for the new banknote system.

Examples

Input 1

6 11 15

Output 1

6

Input 2

99999959 99999971 99999989

Output 2

11

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.