#include <stdio.h>
unsigned bitrev(unsigned n)
{
unsigned r;
for (r = 0; n; n >>= 1) {
r <<= 1;
r |= n & 1;
}
return r;
}
int main()
{
unsigned n;
unsigned n;
scanf("%u", &n);
printf("%u\n", bitrev(n));
return 0;
}