#include <bits/stdc++.h>
using namespace std;

int main() {
  int L;
  cin >> L;
  long long over=1;
  vector<int> ok(10);
  
  for(int i=1; i<=11; i++) {
    over *= (L-i);
    for(int k=2; k<=11; k++) {
      if( (over%k) == 0 && ok.at(k-2) == 0) {
        over /= k;
        ok.at(k-2) = 1;
      }
    }
  }
  cout << over << endl;
}
#ifdef DEBUG_BUILD
# define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#ifdef DEBUG_BUILD
# include "debugger.hpp"
#else
# define debug(...)
# define debugdo(...)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using pll = std::pair<ll, ll>;
template <class T> using vec = std::vector<T>;
template <class T> using vec2 = std::vector<vec<T>>;
template <class T> using vec3 = std::vector<vec2<T>>;
#define rep(i, N) for (ll i = 0; i < (N); i++)
#define rrep(i, N) for (ll i = (N) - 1; i >= 0; i--)
#define range(i, A, B) for (ll i = (A); i < (B); i++)
constexpr int MOD = 1000000007;
constexpr ll INFL = std::numeric_limits<ll>::max();
template <class T> bool chmax(T &a, const T b) { if (a < b) { a = b; return true; } return false; }
template <class T> bool chmin(T &a, const T b) { if (a > b) { a = b; return true; } return false; }

void Main() {
    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    for (auto& c : S) {
        switch(c) {
        case '6':
            c = '9';
            break;
        case '9':
            c = '6';
            break;
        }
    }
    cout << S << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    Main();
    std::cout << std::flush;
    std::cerr << "--end--" << std::flush;
    return 0;
}
