

Input

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

Output

Output a single integer.

Example

Input

3


Output

27
import sun.reflect.generics.tree.Tree;

import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;

/**
 * @author ramilagger
 */

public class Main {

    final static boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;


    void solve() {
        int n = nextInt();
        int [] a = {4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778};
        pw.println(a[n - 1]);
    }



    public static void main(String[] args) {
        new Main();
    }

    void run() throws IOException {
        start = System.currentTimeMillis();
        solve();
        if (!ONLINE_JUDGE)
            System.err.println(System.currentTimeMillis() - start + " ms");
        br.close();
        pw.close();
    }

    Main() {
        try {
            br = (ONLINE_JUDGE) ? new BufferedReader(new InputStreamReader(System.in))
                    : new BufferedReader(new FileReader("in.txt"));
            pw = (ONLINE_JUDGE) ? new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)))
                    : new PrintWriter(new BufferedWriter(new FileWriter("out.txt")));
            this.run();
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException();
        }
    }


    boolean hasNext() {
        if (st != null && st.hasMoreTokens())
            return true;
        try {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
        } catch (Exception e) {
            return false;
        }
        return true;
    }

    String next() {
        if (hasNext())
            return st.nextToken();
        return null;
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    BigInteger nextBigInteger() {
        return new BigInteger(next());
    }

    String nextLine() {
        StringBuilder sb;
        try {
            while (st == null || !st.hasMoreTokens()) return br.readLine();
            sb = new StringBuilder(st.nextToken());
            while (st.hasMoreTokens()) sb.append(" " + st.nextToken());
        } catch (IOException e) {
            throw new RuntimeException();
        }
        return sb.toString();
    }

    int[] nextArray(int n) {
        int[] temp = new int[n];
        for (int i = 0; i < n; i++)
            temp[i] = nextInt();
        return temp;
    }

    long[] nextLArray(int n) {
        long[] temp = new long[n];
        for (int i = 0; i < n; i++)
            temp[i] = nextLong();
        return temp;
    }

    long start;
    final BufferedReader br;
    final PrintWriter pw;
    StringTokenizer st;

}