#include <stdio.h>
#include <stdint.h>
// Complete the function
uint16_t highest_set_bit(uint16_t reg) {
if (reg <= 1) return reg;
int n = 15;
while (!(reg & (1 << n))){
n--; //decrement n until we find the highest set bit
}
for (int i = n-1; i >= 0; i--){
reg &= ~(1 << i); //clear all bits below that
}
return reg;
}
int main() {
uint16_t reg;
scanf("%hu", ®);
uint16_t result = highest_set_bit(reg);
printf("%hu", result);
return 0;
}