import java.util.Scanner;

public class Main {
    static String key = "15051499783199060";
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String S = sc.next();
        String K = sc.next();

        System.out.println(checkInf(S, K));
    }

    public static String checkInf(String S, String K){
        long count = 0;
        for(int i = 0; i < S.length(); i++){
            int val = S.charAt(i) - '0';
            if(val == 1)
                count++;
            else {
                if(K.compareTo(key) > 0 && val == 2){
                    while(i < S.length()){
                        int val1 = S.charAt(i) - '0';
                        if(val1 != 1)
                            return String.valueOf((char) ('0' + val));
                        i++;
                    }
                    return String.valueOf((char) ('0' + val));
                }
                return String.valueOf((char) ('0' + val));
            }
            if(K.compareTo(String.valueOf(count)) == 0)
                return String.valueOf((char)('0' + val));

        }
        return null;
    }
} import java.util.Scanner; Scanner java.util public class Main {
    static String key = "15051499783199060";
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String S = sc.next();
        String K = sc.next();

        System.out.println(checkInf(S, K));
    }

    public static String checkInf(String S, String K){
        long count = 0;
        for(int i = 0; i < S.length(); i++){
            int val = S.charAt(i) - '0';
            if(val == 1)
                count++;
            else {
                if(K.compareTo(key) > 0 && val == 2){
                    while(i < S.length()){
                        int val1 = S.charAt(i) - '0';
                        if(val1 != 1)
                            return String.valueOf((char) ('0' + val));
                        i++;
                    }
                    return String.valueOf((char) ('0' + val));
                }
                return String.valueOf((char) ('0' + val));
            }
            if(K.compareTo(String.valueOf(count)) == 0)
                return String.valueOf((char)('0' + val));

        }
        return null;
    }
} Main static String key = "15051499783199060"; key "15051499783199060" public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String S = sc.next();
        String K = sc.next();

        System.out.println(checkInf(S, K));
    } main {
        Scanner sc = new Scanner(System.in);

        String S = sc.next();
        String K = sc.next();

        System.out.println(checkInf(S, K));
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String S = sc.next(); S sc.next() sc.next sc String K = sc.next(); K sc.next() sc.next sc System.out.println(checkInf(S, K)) System.out.println System.out System System.out checkInf(S, K) checkInf S K String[] args args public static String checkInf(String S, String K){
        long count = 0;
        for(int i = 0; i < S.length(); i++){
            int val = S.charAt(i) - '0';
            if(val == 1)
                count++;
            else {
                if(K.compareTo(key) > 0 && val == 2){
                    while(i < S.length()){
                        int val1 = S.charAt(i) - '0';
                        if(val1 != 1)
                            return String.valueOf((char) ('0' + val));
                        i++;
                    }
                    return String.valueOf((char) ('0' + val));
                }
                return String.valueOf((char) ('0' + val));
            }
            if(K.compareTo(String.valueOf(count)) == 0)
                return String.valueOf((char)('0' + val));

        }
        return null;
    } checkInf {
        long count = 0;
        for(int i = 0; i < S.length(); i++){
            int val = S.charAt(i) - '0';
            if(val == 1)
                count++;
            else {
                if(K.compareTo(key) > 0 && val == 2){
                    while(i < S.length()){
                        int val1 = S.charAt(i) - '0';
                        if(val1 != 1)
                            return String.valueOf((char) ('0' + val));
                        i++;
                    }
                    return String.valueOf((char) ('0' + val));
                }
                return String.valueOf((char) ('0' + val));
            }
            if(K.compareTo(String.valueOf(count)) == 0)
                return String.valueOf((char)('0' + val));

        }
        return null;
    } long count = 0; count 0 for(int i = 0; i < S.length(); i++){
            int val = S.charAt(i) - '0';
            if(val == 1)
                count++;
            else {
                if(K.compareTo(key) > 0 && val == 2){
                    while(i < S.length()){
                        int val1 = S.charAt(i) - '0';
                        if(val1 != 1)
                            return String.valueOf((char) ('0' + val));
                        i++;
                    }
                    return String.valueOf((char) ('0' + val));
                }
                return String.valueOf((char) ('0' + val));
            }
            if(K.compareTo(String.valueOf(count)) == 0)
                return String.valueOf((char)('0' + val));

        } int i = 0; int i = 0; i 0 i < S.length() i S.length() S.length S i++ i++ i {
            int val = S.charAt(i) - '0';
            if(val == 1)
                count++;
            else {
                if(K.compareTo(key) > 0 && val == 2){
                    while(i < S.length()){
                        int val1 = S.charAt(i) - '0';
                        if(val1 != 1)
                            return String.valueOf((char) ('0' + val));
                        i++;
                    }
                    return String.valueOf((char) ('0' + val));
                }
                return String.valueOf((char) ('0' + val));
            }
            if(K.compareTo(String.valueOf(count)) == 0)
                return String.valueOf((char)('0' + val));

        } {
            int val = S.charAt(i) - '0';
            if(val == 1)
                count++;
            else {
                if(K.compareTo(key) > 0 && val == 2){
                    while(i < S.length()){
                        int val1 = S.charAt(i) - '0';
                        if(val1 != 1)
                            return String.valueOf((char) ('0' + val));
                        i++;
                    }
                    return String.valueOf((char) ('0' + val));
                }
                return String.valueOf((char) ('0' + val));
            }
            if(K.compareTo(String.valueOf(count)) == 0)
                return String.valueOf((char)('0' + val));

        } int val = S.charAt(i) - '0'; val S.charAt(i) - '0' S.charAt(i) S.charAt S i '0' if(val == 1)
                count++;
            else {
                if(K.compareTo(key) > 0 && val == 2){
                    while(i < S.length()){
                        int val1 = S.charAt(i) - '0';
                        if(val1 != 1)
                            return String.valueOf((char) ('0' + val));
                        i++;
                    }
                    return String.valueOf((char) ('0' + val));
                }
                return String.valueOf((char) ('0' + val));
            } val == 1 val 1 count++ count {
                if(K.compareTo(key) > 0 && val == 2){
                    while(i < S.length()){
                        int val1 = S.charAt(i) - '0';
                        if(val1 != 1)
                            return String.valueOf((char) ('0' + val));
                        i++;
                    }
                    return String.valueOf((char) ('0' + val));
                }
                return String.valueOf((char) ('0' + val));
            } if(K.compareTo(key) > 0 && val == 2){
                    while(i < S.length()){
                        int val1 = S.charAt(i) - '0';
                        if(val1 != 1)
                            return String.valueOf((char) ('0' + val));
                        i++;
                    }
                    return String.valueOf((char) ('0' + val));
                } K.compareTo(key) > 0 && val == 2 K.compareTo(key) > 0 K.compareTo(key) K.compareTo K key 0 val == 2 val 2 {
                    while(i < S.length()){
                        int val1 = S.charAt(i) - '0';
                        if(val1 != 1)
                            return String.valueOf((char) ('0' + val));
                        i++;
                    }
                    return String.valueOf((char) ('0' + val));
                } while(i < S.length()){
                        int val1 = S.charAt(i) - '0';
                        if(val1 != 1)
                            return String.valueOf((char) ('0' + val));
                        i++;
                    } i < S.length() i S.length() S.length S {
                        int val1 = S.charAt(i) - '0';
                        if(val1 != 1)
                            return String.valueOf((char) ('0' + val));
                        i++;
                    } int val1 = S.charAt(i) - '0'; val1 S.charAt(i) - '0' S.charAt(i) S.charAt S i '0' if(val1 != 1)
                            return String.valueOf((char) ('0' + val)); val1 != 1 val1 1 return String.valueOf((char) ('0' + val)); String.valueOf((char) ('0' + val)) String.valueOf String (char) ('0' + val) '0' val i++ i return String.valueOf((char) ('0' + val)); String.valueOf((char) ('0' + val)) String.valueOf String (char) ('0' + val) '0' val return String.valueOf((char) ('0' + val)); String.valueOf((char) ('0' + val)) String.valueOf String (char) ('0' + val) '0' val if(K.compareTo(String.valueOf(count)) == 0)
                return String.valueOf((char)('0' + val)); K.compareTo(String.valueOf(count)) == 0 K.compareTo(String.valueOf(count)) K.compareTo K String.valueOf(count) String.valueOf String count 0 return String.valueOf((char)('0' + val)); String.valueOf((char)('0' + val)) String.valueOf String (char)('0' + val) '0' val return null; null String S S String K K public class Main {
    static String key = "15051499783199060";
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String S = sc.next();
        String K = sc.next();

        System.out.println(checkInf(S, K));
    }

    public static String checkInf(String S, String K){
        long count = 0;
        for(int i = 0; i < S.length(); i++){
            int val = S.charAt(i) - '0';
            if(val == 1)
                count++;
            else {
                if(K.compareTo(key) > 0 && val == 2){
                    while(i < S.length()){
                        int val1 = S.charAt(i) - '0';
                        if(val1 != 1)
                            return String.valueOf((char) ('0' + val));
                        i++;
                    }
                    return String.valueOf((char) ('0' + val));
                }
                return String.valueOf((char) ('0' + val));
            }
            if(K.compareTo(String.valueOf(count)) == 0)
                return String.valueOf((char)('0' + val));

        }
        return null;
    }
} public class Main {
    static String key = "15051499783199060";
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String S = sc.next();
        String K = sc.next();

        System.out.println(checkInf(S, K));
    }

    public static String checkInf(String S, String K){
        long count = 0;
        for(int i = 0; i < S.length(); i++){
            int val = S.charAt(i) - '0';
            if(val == 1)
                count++;
            else {
                if(K.compareTo(key) > 0 && val == 2){
                    while(i < S.length()){
                        int val1 = S.charAt(i) - '0';
                        if(val1 != 1)
                            return String.valueOf((char) ('0' + val));
                        i++;
                    }
                    return String.valueOf((char) ('0' + val));
                }
                return String.valueOf((char) ('0' + val));
            }
            if(K.compareTo(String.valueOf(count)) == 0)
                return String.valueOf((char)('0' + val));

        }
        return null;
    }
} Main
import java.util.Scanner;

public class Main {
    static String key = "15051499783199060";
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String S = sc.next();
        String K = sc.next();

        System.out.println(checkInf(S, K));
    }

    public static String checkInf(String S, String K){
        long count = 0;
        for(int i = 0; i < S.length(); i++){
            int val = S.charAt(i) - '0';
            if(val == 1)
                count++;
            else {
                if(K.compareTo(key) > 0 && val == 2){
                    while(i < S.length()){
                        int val1 = S.charAt(i) - '0';
                        if(val1 != 1)
                            return String.valueOf((char) ('0' + val));
                        i++;
                    }
                    return String.valueOf((char) ('0' + val));
                }
                return String.valueOf((char) ('0' + val));
            }
            if(K.compareTo(String.valueOf(count)) == 0)
                return String.valueOf((char)('0' + val));

        }
        return null;
    }
}
