import java.io.*;
public class Main {

	public static void main(String[] args)throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String A = br.readLine();
		long B = Long.parseLong(br.readLine());
		String ans = "1";
		long count = 0;
		for(int i =0; i<A.length(); i++) {
			String sub = A.substring(i,i+1);
			if(A.substring(i,i+1).equals("1")) {
				count++;
			}
		
		
			else if(!sub.equals("1")) {
				ans = sub;
				break;
			}
		}
		if(count>=B) {
			System.out.println("1");
		}
		else {
			System.out.println(ans);
		}
	}

}

/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz