Under construction

Still being built. Things may change

Integer Equation Checker

Time limit1sMemory limit512 MB

Summary
Classify an equation string as correct, format error, math error, or a typo fixable by replacing at most two characters with a valid correct equation.
Level

Hard9 of 10

Topics
Brute force, Implementation, String, Math
Solved
No attempts yet

Problem

In this task you need to create a checker for integer equations with error correction.

The integer equation is given in the form:

<number1><operation><number2>=<number3>

wherein "<numberI>" denotes any positive integer less than or equal to 10910^9 without leading zeros, and "<operation>" is one of the signs '+', '-', '*' or '/' that represents one of the four basic math operations (note that unary plus and unary minus are not allowed). An expression that satisfies these properties is called well-formatted.

The checker shall read the equations and give the outcome in the next way:

  • Correct --- a well-formatted mathematically correct equation is given.
  • Format Error --- the given equation does not match the default format.
  • Typo: <equation1> instead of <equation2> --- the given equation (<equation1>) is well-formatted but not mathematically correct and is is enough to replace up to two characters in it to obtain a mathematically correct and well-formatted equation (<equation2>).
  • Math Error --- the given equation is well-formatted, mathematically incorrect, and it is impossible to correct two or less characters and obtain a well-formatted and mathematically correct equation.

Note that characters can be only replaced, they cannot be inserted or deleted.

Input

The first line of the input contains a non-empty string of up to 30 characters that represents the equation to be checked. This word consists only of decimal digits ('0' - '9'), arithmetic operators ('+', '-', '*', and '/') and equality signs ('=').

Output

Print the result of evaluation. Refer to the samples for clarity.

Examples5

  1. Example 1

    Input
    2-2=0
    
    Expected output
    Format Error
    
  2. Example 2

    Input
    7/2=3
    
    Expected output
    Typo: 7/2=3 instead of 6/2=3
    
  3. Example 3

    Input
    2*2=47
    
    Expected output
    Math Error
    
  4. Example 4

    Input
    239*2=237
    
    Expected output
    Typo: 239*2=237 instead of 239-2=237
    
  5. Example 5

    Input
    112*11=13
    
    Expected output
    Math Error