public static void main(String[] args){
		Scanner in=new Scanner(System.in);
		long m = in.nextLong();
		k=in.nextInt();
		f[0]=1; f[1]=1;
		
		while(MAX>MIN){
			long mid = (MAX+MIN)/2;
			long c = count(mid);
			if(c==m){
				System.out.println(mid);
				return;
			}else{
				if(c < m) MIN = mid+1;
				else MAX = mid-1;
//				System.out.println(MAX + " " + mid + " " + MIN);
			}
		}
		
	}