cho.sh
Notes
Loading...

Octopus Numbers

Time limit

1s

Memory limit

128 MB

Problem

On parts of the seafloor where currents are very slow and almost no creatures crawl along the bottom, mysterious ripple patterns have long been observed. Researchers have recently discovered that these patterns are how octopuses write numbers. Although nobody yet knows what the octopuses are counting, their notation has been decoded.

Researchers agreed to write the ripple patterns with the following nine symbols. Each symbol represents the value shown below.

  • - represents 0.
  • \ represents 1.
  • ( represents 2.
  • @ represents 3.
  • ? represents 4.
  • > represents 5.
  • & represents 6.
  • % represents 7.
  • / represents -1.

An octopus number uses powers of 8 as place values. For example, (@& is 2 × 8^2 + 3 × 8 + 6 = 158, and ?/-- is 4 × 8^3 + (-1) × 8^2 + 0 × 8 + 0 = 1984. Also, /(\ is (-1) × 8^2 + 2 × 8 + 1 = -47.

Given octopus numbers, convert each one to its decimal value and print it.

Input

The input consists of several lines. Each line contains one octopus number, made of at least 1 and at most 8 symbols. A line containing # ends the input.

Output

For each octopus number in the input, print the corresponding decimal value on its own line.