import java.util.Scanner; public class Bitsugoroku { static int N; static boolean tof = false; public static void main(String[] args) { Scanner s = new Scanner(System.in); int p = 1,count = 1; N = s.nextInt(); s.close(); if(N == 1){ count = 1; }else{ int h = Sugo(p,count); if(h == 0){ count = 0; }else{ count += h; } } if(count == 0){ System.out.println(-1); }else{ System.out.println(count); } } static int Sugo(int p,int count){ int d = Integer.bitCount(p); if(p + d > N){ tof = true; int k = Sugo(p - d,count); if(k == 0){ count = 0; }else{ count += k; } }else if(p + d == N){ count = 1; }else if(p - d <= 3 && tof){ count = 0; }else{ int h = Sugo(p+d,count); if(h==0){ count = 0; }else{ count += h; } } return count; } }