import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int n = N;
        int c = 0;
        for (int i = N; i > 0; i--) {
            int ic = cnt(i);
            if (ic > c) {
                c = ic;
                n = i;
            }
        }
        System.out.println(n);
    }

    static int cnt(int n) {
        int c = 0;
        while (n > 0) {
            if (n % 2 != 0) {
                break;
            }
            n /= 2;
            c++;
        }
        return c;
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int n = N;
        int c = 0;
        for (int i = N; i > 0; i--) {
            int ic = cnt(i);
            if (ic > c) {
                c = ic;
                n = i;
            }
        }
        System.out.println(n);
    }

    static int cnt(int n) {
        int c = 0;
        while (n > 0) {
            if (n % 2 != 0) {
                break;
            }
            n /= 2;
            c++;
        }
        return c;
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int n = N;
        int c = 0;
        for (int i = N; i > 0; i--) {
            int ic = cnt(i);
            if (ic > c) {
                c = ic;
                n = i;
            }
        }
        System.out.println(n);
    } main {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int n = N;
        int c = 0;
        for (int i = N; i > 0; i--) {
            int ic = cnt(i);
            if (ic > c) {
                c = ic;
                n = i;
            }
        }
        System.out.println(n);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = scanner.nextInt(); N scanner.nextInt() scanner.nextInt scanner int n = N; n N int c = 0; c 0 for (int i = N; i > 0; i--) {
            int ic = cnt(i);
            if (ic > c) {
                c = ic;
                n = i;
            }
        } int i = N; int i = N; i N i > 0 i 0 i-- i-- i {
            int ic = cnt(i);
            if (ic > c) {
                c = ic;
                n = i;
            }
        } {
            int ic = cnt(i);
            if (ic > c) {
                c = ic;
                n = i;
            }
        } int ic = cnt(i); ic cnt(i) cnt i if (ic > c) {
                c = ic;
                n = i;
            } ic > c ic c {
                c = ic;
                n = i;
            } c = ic c ic n = i n i System.out.println(n) System.out.println System.out System System.out n String[] args args static int cnt(int n) {
        int c = 0;
        while (n > 0) {
            if (n % 2 != 0) {
                break;
            }
            n /= 2;
            c++;
        }
        return c;
    } cnt {
        int c = 0;
        while (n > 0) {
            if (n % 2 != 0) {
                break;
            }
            n /= 2;
            c++;
        }
        return c;
    } int c = 0; c 0 while (n > 0) {
            if (n % 2 != 0) {
                break;
            }
            n /= 2;
            c++;
        } n > 0 n 0 {
            if (n % 2 != 0) {
                break;
            }
            n /= 2;
            c++;
        } if (n % 2 != 0) {
                break;
            } n % 2 != 0 n % 2 n 2 0 {
                break;
            } break; n /= 2 n 2 c++ c return c; c int n n public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int n = N;
        int c = 0;
        for (int i = N; i > 0; i--) {
            int ic = cnt(i);
            if (ic > c) {
                c = ic;
                n = i;
            }
        }
        System.out.println(n);
    }

    static int cnt(int n) {
        int c = 0;
        while (n > 0) {
            if (n % 2 != 0) {
                break;
            }
            n /= 2;
            c++;
        }
        return c;
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int n = N;
        int c = 0;
        for (int i = N; i > 0; i--) {
            int ic = cnt(i);
            if (ic > c) {
                c = ic;
                n = i;
            }
        }
        System.out.println(n);
    }

    static int cnt(int n) {
        int c = 0;
        while (n > 0) {
            if (n % 2 != 0) {
                break;
            }
            n /= 2;
            c++;
        }
        return c;
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int n = N;
        int c = 0;
        for (int i = N; i > 0; i--) {
            int ic = cnt(i);
            if (ic > c) {
                c = ic;
                n = i;
            }
        }
        System.out.println(n);
    }

    static int cnt(int n) {
        int c = 0;
        while (n > 0) {
            if (n % 2 != 0) {
                break;
            }
            n /= 2;
            c++;
        }
        return c;
    }
}