package main
import (
"bufio"
"fmt"
"math"
"os"
"strings"
)
// 得到输入内容
func getPrintStr() (str string) {
reader := bufio.NewReader(os.Stdin)
str, _ = reader.ReadString('\n')
str = strings.TrimSuffix(str, "\n")
str = str[2:]
// fmt.Println(str)
return
}
func getResult(str string) {
result := 0
for i := 0; i < len(str); i++ {
value := 0
if str[i] >= '0' && str[i] <= '9' {
value = int(str[i] - '0')
} else {
value = int(str[i] - 'A' + 10)
}
result += value*int(math.Pow(16, float64(len(str) - i - 1)))
// positionWeight := 1
// for j := 0; j < len(str) - i - 1; j ++ {
// positionWeight *= 16
// }
// result += value*positionWeight
}
fmt.Println(result)
}
func main() {
str := getPrintStr()
getResult(str)
}