Busy Friend

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Time Limit: 1.0 s

Memory Limit: 256.0 MB

Description

Abidur gave his friend Umaer an arighmetic sequence of numbers. But since Umaer was a busy person and the sequence was too long, he didn’t want to write the entire expression.
Instead, Umaer wrote only the first few numbers with plus signs and then replaced the remaining numbers and plus signs with dots (...). While writing the dots, Umaer got bored and decided not to write all of them.
For example:
• The sequence \(1+3+5+7\) may be written as \(1+3+5..\)
• The sequence \(5+6+7+8+9+10\) may be written as \(5+6+...\)
Umaer only remembered how many numbers were in the full sequence.
Now your task is to help Umaer find the sum of the sequence.

Input

Each test case contains two lines:
• A string S – the partially written sequence with dots (.).
• An integer \(N (2 ≤ N ≤ 10^8)\) – the total number of terms in the sequence.
The string S will always start with at least two positive numbers separated by +. The dots (...) mean the sequence continues with the same difference until it reaches N terms in total.

Output

For each test case, output the sum of the sequence.

Sample

Input Output
1+3+...
5
25

LUCC Presents Intra LU Junior Programming Contest - Replay

Not Attended
Status
Done
Rule
ACM/ICPC
Problem
10
Start at
2025-09-02 15:30
End at
2025-09-02 17:45
Duration
2.2 hour(s)
Host
Partic.
65