import sys
def solve():
"""
Solves a single test case for the arithmetic sequence sum problem.
"""
try:
s = sys.stdin.readline().strip()
n = int(sys.stdin.readline())
except (IOError, ValueError):
# Stop if there's no more input
return False
# Clean up the string to extract the numbers
# We only need the first number, which is the start of the sequence
parts = s.replace('+', ' ').replace('...', ' ').split()
if not parts:
# Handle cases with empty or malformed strings gracefully
return True
# The first term of the arithmetic progression
first_term = int(parts[0])
# The number of terms is N
num_terms = n
# The common difference is 1 for consecutive numbers
difference = 1
# Using the formula for the sum of an arithmetic series:
# Sum = n/2 * (2*a + (n-1)*d)
# Since n can be large, we should use integer arithmetic that avoids floats
# by calculating (n * (2*a + (n-1)*d)) // 2
sum_val = (num_terms * (2 * first_term + (num_terms - 1) * difference)) // 2
print(sum_val)
return True
def main():
"""
Main loop to handle all test cases from stdin.
"""
while solve():
pass
if __name__ == "__main__":
main()