

Input

The input contains a single integer a (1 ≤ a ≤ 30).

Output

Output a single integer.

Example

Input

3


Output

27
    import java.util.*;

    /**
     * Created by Lenovo on 06-12-2016.
     */
     public class b {
        public static void main(String args[]) {
            Scanner in = new Scanner(System.in);
            int n = in.nextInt();
            HashMap<Integer,Integer>hm=new HashMap<>();
            hm.put(1,4);
            hm.put(2,22);
            hm.put(3,27);
            hm.put(4,58);
            hm.put(5,85);
            hm.put(6,94);
            hm.put(7,121);
            hm.put(8,166);
            hm.put(9,202);
            hm.put(10,265);
            hm.put(11,274);
            hm.put(12,319);
            hm.put(13,346);
            hm.put(14,355);
            hm.put(15,378);
            hm.put(16,382);
            hm.put(17,391);
            hm.put(18,438);
            hm.put(19,454);
            hm.put(20,483);
            hm.put(21,517);
            hm.put(22,526);
            hm.put(23,535);
            hm.put(24,562);
            hm.put(25,576);
            hm.put(26,588);
            hm.put(27,627);
            hm.put(28,634);
            hm.put(29,636);
            hm.put(30,645);
            System.out.println(hm.get(n));







        }
    }