#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
int hd, tl, sta[N][N], dig[N][N];
pair<int, int> q[N * 1500], pre[N][N], tt;
inline string solve(int A) {
  memset(sta, -1, sizeof(sta));
  sta[0][((0) + 1500)] = 0;
  q[hd = tl = 1] = pair<int, int>(0, 0);
  while (hd <= tl) {
    int car = q[hd].first, bal = q[hd].second;
    for (register int tmp, ncar, nbal, num = hd > 1 ? 0 : 1; num < 10; ++num) {
      tmp = car * 10 + num;
      ncar = tmp % A;
      nbal = bal + A * num - tmp / A;
      if (((nbal) + 1500) > 3000 || ((nbal) + 1500) < 0) continue;
      if (!nbal && !ncar) {
        string ret = "", tret = "";
        tret += (char)(num ^ 48);
        while (car || bal) {
          tret += (char)(dig[car][((bal) + 1500)] ^ 48);
          tt = pre[car][((bal) + 1500)];
          car = tt.first, bal = tt.second;
        }
        reverse(tret.begin(), tret.end());
        for (register int sum = 0, i = 0, up = tret.size(); i ^ up; ++i) {
          sum = sum * 10 + (tret[i] ^ 48);
          if (sum / A || ret.size()) ret += (char)((sum / A) ^ 48);
          sum %= A;
        }
        return ret;
      }
      if (sta[ncar][((nbal) + 1500)] == -1) {
        sta[ncar][((nbal) + 1500)] = sta[car][((bal) + 1500)] + 1;
        q[++tl] = pair<int, int>(ncar, nbal);
        pre[ncar][((nbal) + 1500)] = pair<int, int>(car, bal);
        dig[ncar][((nbal) + 1500)] = num;
      }
    }
    ++hd;
  }
  return "-1";
}
int main() {
  int A;
  scanf("%d", &A);
  cout << solve(A);
  return 0;
}
