#include <stdio.h> int main() { char arr[128]; while(EOF != scanf("%s", arr)) { int len = strlen(arr), p = 1; int sum = 0; for(int i = len-1; i > 1; i--) { if(arr[i] >= '0' && arr[i] <= '9') { sum += (arr[i] - '0') * p; } else { sum += (arr[i] - 'A' + 10) * p; } p *= 16; } printf("%d\n", sum); } return 0; }