AlgoUniversity
  • Go Back
Discussion
Bodmas Rule :

Author

Gurankit Pal Singh

Difficulty Level : Hard

Submissions : 433

Asked In : Flipkart

Marks :10

: 8 | : 2

You are given a mathematical expression, consisting of "+", "-" and "*" operators. Answer to the expression can be correct, partially correct, or wrong.

Correct answer of the expression is obtained by applying BODMAS rule. Partially correct answers are obtained if there is a mistake in application of BODMAS rule.

You are also given an array of $$$n$$$ integers. For the integers corresponding to correct answer score 5 is given, for partially correct answer score 2 is given, and for wrong answer no score is given. Determine the sum of scores for all the $$$n$$$ integers.

Input

The first line contains a string $$$s$$$, denoting the mathematical expression. $$$(1 \le |s| \le 30)$$$.

The second line contains an integer $$$n$$$, denoting the number of integers in the array. $$$(1 \le n \le 1000)$$$

The third line contains $$$n$$$ integers.

Output

Print the sum of scores for all the integers.

Example

Input
5*4-3*2
4
-10 10 14 90
Output
9

Note

In the given sample case, possible answers for the expression are:

  • (5*4)-(3*2) = 14 (Correct answer)
  • 5*(4-3)*2 = 10
  • (5*4-3)*2 = 34
  • 5*(4-3*2) = -10

There is 1 correct answer and 2 partially correct answers in the given integers. So the answer will be 5+2+2 = 9

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.