import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {

        // 1.接收数据并处理
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        String[] strs = str.split(" ");
        String strA = strs[0];
        int da = Integer.parseInt(strs[1]);
        String strB = strs[2];
        int db = Integer.parseInt(strs[3]);
        int pa = 0;
        int pb = 0;
        int countDA = 0;    // 记录da在a中出现的次数
        int countDB = 0;    // 记录db在a中出现的次数
        for(int i = 0 ; i < strA.length() ; i++) {
            if(strA.charAt(i) - '0' == da ) {
                countDA ++;
                if(countDA == 1) {
                    pa = da;
                } else {
                    pa += da * (int)Math.pow(10,countDA - 1);
                }
            }
        }
        for(int i = 0 ; i < strB.length() ; i++) {
            if(strB.charAt(i) - '0' == db) {
                countDB ++;
                if(countDB == 1) {
                    pb = db;
                } else {
                    pb += db * (int)Math.pow(10,countDB - 1);
                }
            }
        }
        System.out.println(pa+pb);

    }
}