package com.thinker.bishi.saima;

import java.util.Scanner;

/**
 * @author lzh
 * @apiNote 题目描述:
 *   <p href="http://exercise.acmcoder.com/online/online_judge_ques?ques_id=1667&konwledgeId=134">
 *       http://exercise.acmcoder.com/online/online_judge_ques?ques_id=1667&konwledgeId=134
 *   </p>
 *
 */
public class PassWord {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int l = in.nextInt();
        int r = in.nextInt();
        int m = in.nextInt();
        if(l>r){
            System.out.println(-1);
            return;
        }
        int count = 0;
        for(int i=l;i<=r;i++){
            if(check(i,m)) count ++;
        }
        if(count == 0){
            System.out.println(-1);
        }else {
            System.out.println(count);
        }

    }

    private static boolean check(int n,int m){
        while(n != 0){
            if((n&1) == 1) m--;
            n = n >> 1;
        }
        if(m == 0){
            return true;
        }
        return false;
    }
}
