#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int x;
cin >>hex >> x;
cout << x << endl;
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int hexadecimaltoDecimal(string n)
{
int ans = 0;
int x = 1;
int s = n.size();
for( int i=s-1 ; i>=0 ; i-- )
{
if( n[i] >= '0' && n[i] <= '9' )
{
ans += x*( n[i] - '0' );
}
else if( n[i] >= 'A' && n[i] <= 'F' )
{
ans += x*( n[i] - 'A' + 10 );
}
x *= 16;
}
return ans;
}
int main()
{
string n;
cout<<"Input a Hexa Decimal number :"<<endl;
cin>>n;
cout<<"The Decimal number will be :"<<endl;
cout<<hexadecimaltoDecimal(n)<<endl;
return 0;
}
#include <iostream>
#include <string>
#include "math.h"
using namespace std;
unsigned long hex2dec(string hex)
{
unsigned long result = 0;
for (int i=0; i<hex.length(); i++) {
if (hex[i]>=48 && hex[i]<=57)
{
result += (hex[i]-48)*pow(16,hex.length()-i-1);
} else if (hex[i]>=65 && hex[i]<=70) {
result += (hex[i]-55)*pow(16,hex.length( )-i-1);
} else if (hex[i]>=97 && hex[i]<=102) {
result += (hex[i]-87)*pow(16,hex.length()-i-1);
}
}
return result;
}
int main(int argc, const char * argv[]) {
string hex_str;
cin >> hex_str;
cout << hex2dec(hex_str) << endl;
return 0;
}