import java.util.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String ip = sc.nextLine();
        long add=sc.nextLong();
        dec(ip);
        ipFormat(add);
    }
    private static void dec(String ip) {
        String []ips = ip.split("\\.");
        //String转int
        int []int_ips = new int [4];
        for (int i = 0; i < 4; i++)
            int_ips[i] = Integer.parseInt(ips[i]);
        //十进制转任意进制,存入temp中
        StringBuilder temp = new StringBuilder();
        for (int x : int_ips) {
            //转二进制
            String binary = Integer.toString(x, 2);
            //格式化为8位,空余补0
            String binary_ = String.format("%8s", binary).replace(' ', '0');
            //推入到temp中
            temp.append(binary_);
        }
        //处理完所有的ips,任意进制转10进制输出答案
        //字符串转整型
        long ans = Long.parseLong(temp.toString(), 2);
        System.out.println(ans);
    }
    private static void ipFormat(long add){
        //十进制转二进制
        String binary=Long.toString(add,2);
        String binary_=String.format("%32s",binary).replace(' ','0');
        //取出4组ip放入ips中
        String []ips=new String[4];
        int j=0;
        for(int i=0;i<32;i+=8){
            ips[j++]=binary_.substring(i,i+8);
        }
        StringBuilder ans=new StringBuilder();
        //再将ips中的4个ip转十进制
        for(String str:ips){
            ans.append(Integer.parseInt(str,2));
            ans.append(".");
        }
        ans.deleteCharAt(ans.length()-1);
        System.out.println(ans.toString());
    }
}