import java.util.*; import java.io.*; import java.math.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); long m = sc.nextLong(); long max_2 = 1; int cnt = 0; for(int i = 1; i <= 128; i++){ max_2 *= 2; if(max_2 >= m){ cnt = i; break; } } long ans = max_2 % m; for(int i = cnt+1; i <= 128; i++){ ans = (ans*2)%m; } System.out.println(ans); } }