/
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 100 点
問題文
ある星では 1 年が D 日あり、7 日ごとにコンテストが開催されています。コンテストが日をまたいで開催されることはありません。
ある年の最初のコンテストは 1 年のうち F 日目に開催されました。その次の年の最初のコンテストは 1 年のうち何日目に開催されますか?
なお、この問題の制約のもとでは、次の年にコンテストが 1 回以上開催されることが保証されます。
制約
- 10 \leq D \leq 366
- 1 \leq F \leq 7
- 入力される値はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
D F
出力
答えを出力せよ。
入力例 1
365 4
出力例 1
3
ある年の最初のコンテストの開催が 1 年のうち 4 日目だったとき、次の年の最初のコンテストの開催は 1 年のうち 3 日目になります。
入力例 2
10 5
出力例 2
2
Score : 100 points
Problem Statement
On a certain planet, a year has D days, and contests are held every 7 days. Contests never span across days.
The first contest of a certain year was held on the F-th day of the year. On what day of the next year will the first contest of the next year be held?
The constraints of this problem guarantee that at least one contest will be held in the next year.
Constraints
- 10 \leq D \leq 366
- 1 \leq F \leq 7
- All input values are integers.
Input
The input is given from Standard Input in the following format:
D F
Output
Print the integer N such that the next contest is held on the N-th day of the year.
Sample Input 1
365 4
Sample Output 1
3
If the first contest of a certain year was held on the 4th day of the year, the first contest of the next year will be held on the 3rd day of the year.
Sample Input 2
10 5
Sample Output 2
2