import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        Set<Character> hs = new HashSet<>();
        while (in.hasNext()) { 
            String ss = in.nextLine();
            String ls = in.nextLine();
            for(int i =0; i<ls.length(); i++){
                hs.add(ls.charAt(i));
            }
            boolean flag = true;
            for(int i = 0; i<ss.length(); i++){
                if(hs.add(ss.charAt(i))){
                    flag = false;
                }
            }
            System.out.print(flag);
        }
    }
}