QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 128 MB 總分: 100

#4850. Mathematics

统计

Little Igor did not practice mathematics at all over the summer holidays, so a few days before school started, he realized he no longer remembered basic mathematical operations. Now he is pestering his brother Davor to help him practice.

To make the practice interesting, Davor told Igor to think of an integer. Then, he told him several times to add, subtract, multiply, or divide the thought-of number by another integer. When performing division, Igor always uses integer division (for example, dividing $-27$ by $10$ results in $-2$). At the end of the practice, Igor says the final result out loud, and it is up to Davor to guess which number Igor thought of at the beginning.

Write a program that, based on the given operations and the final result, determines how many different numbers Igor could have thought of.

Input

The first line contains a natural number $N$ ($1 \le N \le 10$), the number of operations.

Each of the following $N$ lines contains one operation in one of the four forms: "DODAJ x", "ODUZMI x", "POMNOZI SA x", "PODIJELI SA x", where $x$ is an integer, $1 \le x \le 9$.

The last line contains the final result, an integer $R$ ($-100 \le R \le 100$).

Output

Print the number of different integers Igor could have thought of in the first and only line.

Examples

Input 1

1
POMNOZI SA 5
8

Output 1

0

Note 1

There is no integer that, when multiplied by $5$, gives $8$.

Input 2

2
POMNOZI SA 3
PODIJELI SA 2
-1

Output 2

1

Note 2

The only number Igor could have thought of is $-1$.

Input 3

4
DODAJ 5
PODIJELI SA 5
ODUZMI 5
PODIJELI SA 5
1

Output 3

25

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.