import math n = int(input()) if(n==1): print(-1); quit(); wp = -1; c = m = 1; while(1): c = c + 1; s = str(bin(m)).count('1'); m = m + s; if (m > n): if (wp == m): print(-1); break; wp = m; m = m - s*2;7 elif (m == n): print(c); break;