#C9564. Hexadecimal to Decimal Conversion

    ID: 53671 Type: Default 1000ms 256MiB

Hexadecimal to Decimal Conversion

Hexadecimal to Decimal Conversion

Given a hexadecimal string S, your task is to convert it to its decimal representation. The string may consist of digits (0-9) and letters (A-F or a-f). If the string contains any invalid characters, your program should output -1 instead.

The conversion should follow the standard hexadecimal conversion rules. For example, the hexadecimal string 1a corresponds to the decimal number 26, and AbCdEf corresponds to 11259375. Note that the conversion is case-insensitive.

Hint: You may find it useful to consider using the base conversion functions provided by your programming language, but be careful to handle exceptions or errors when invalid characters appear.

inputFormat

The input consists of a single line containing a non-empty string S representing a hexadecimal number.

Constraints: The string may contain digits (0-9) and letters (A-F or a-f). It may also contain leading zeros.

outputFormat

Output the decimal representation of the hexadecimal number. If the input contains any invalid characters (i.e. characters not in [0-9, a-f, A-F]), print -1.

## sample
1a
26