Polynomial
Vasyl has been tasked with solving several math problems that require finding the value of a polynomial. He wants to create a program that, given a polynomial and a specific value for x, computes the result. Your task is to write this program!
Input
The first line of the input contains a polynomial expressed as a sum of monomials. Each monomial is separated by a + or – sign. The first monomial may optionally be preceded by a – sign. A monomial can be written in one of the following forms:
[<Coefficient>*]x[^<Exponent>]
or simply as
<Coefficient>
Here, <Coefficient> is a natural number not greater than 100, x is the variable (always represented by the lowercase letter x), and <Exponent> is a natural number not exceeding 4. Elements enclosed in square brackets are optional. The second line contains a single integer, which is the value of x.
All numbers in the input are within the absolute value of 100. The polynomial consists of no more than 10 monomials, and there may be multiple monomials with the same degree.
Output
The output should be a single number, representing the value of the polynomial for the given value of x.