#include using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) begin(v),end(v) template inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; } using ll = long long; using pii = pair; constexpr ll INF = 1ll<<30; constexpr ll longINF = 1ll<<60; constexpr ll MOD = 1000000007; constexpr bool debug = false; //---------------------------------// int main() { int N; cin >> N; --N; vector a[3] {{0, 1, 2}, {0, 0, 1, 2}, {0, 1, 2, 3, 4, 5}}; vector b[3] {{3, 4, 5}, {3, 4, 5, 6}, {6, 3, 5, 7, 8}}; vector c[3] {{1, 6, 2, 1}, {7, 8, 1, 2, 9}, {1, 3, 9, 4, 3, 9}}; vector ord(10); // ord[i] := i に対応する数字 iota(ALL(ord), 0); while (next_permutation(ALL(ord))) { int na = 0, nb = 0; if (ord[a[N][0]] == 0 || ord[b[N][0]] == 0) continue; REP(i, a[N].size()) { na *= 10; na += ord[a[N][i]]; } REP(i, b[N].size()) { nb *= 10; nb += ord[b[N][i]]; } int nc = na + nb; string sc = to_string(nc); if (sc.size() != c[N].size()) continue; bool ng = false; REP(i, c[N].size()) ng |= sc[i] - '0' != ord[c[N][i]]; if (ng) continue; cout << nc << endl; return 0; } }