using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; class TEST{ static void Main(){ Sol mySol =new Sol(); mySol.Solve(); } } class Sol{ public void Solve(){ int b = -1; if(N != 0){ for(int j=31;j>=0;j--){ if( (N >> j) % 2 == 1){ b = j; break; } } } if((1L << (b + 1)) <= 2 * K){ Console.WriteLine("INF"); return; } int Kmax = 300; int Ofs = 2 * Kmax; long[] dp = new long[4 * Kmax]; dp[0 + Ofs] = 1; long v = 1; for(int i=0;i<31;i++){ if((N >> i) % 2 == 1){ v *= 2; continue; } var ndp = new long[4 * Kmax]; for(int j=0;j< 4 * Kmax;j++){ if(dp[j] == 0) continue; ndp[j] += dp[j]; if(j + v < 4 * Kmax) ndp[j + v] += dp[j]; if(j - v >= 0 ) ndp[j - v] += dp[j]; } dp = ndp; v *= 2; } long ans = 0; for(int i=0;i<=K;i++) ans += dp[i + Ofs]; Console.WriteLine(ans); } int N,K; public Sol(){ var d = ria(); N = d[0]; K = d[1]; } static String rs(){return Console.ReadLine();} static int ri(){return int.Parse(Console.ReadLine());} static long rl(){return long.Parse(Console.ReadLine());} static double rd(){return double.Parse(Console.ReadLine());} static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);} static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));} static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));} static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));} }