#include <iostream>
using namespace std;
bool Cheking(bool arr[]) {
bool q = true;
for (int i = 0; i < 10; i++) if (arr[i] == false) q = false;
if (q == false) return true;
else return false;
}
void Filling(bool arr[], long a) {
int b;
while (a > 0) {
b = a % 10;
arr[b] = (bool)1;
a = (a - b) / 10;
}
}
int main() {
long n, k;
bool arr[10];
while (cin >> n) {
k = 0;
for (int i = 0; i < 10; i++) arr[i] = 0;
while (Cheking(arr)) {
k++;
Filling(arr, k * n);
}
cout << k << '\n';
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwpib29sIENoZWtpbmcoYm9vbCBhcnJbXSkgewogIGJvb2wgcSA9IHRydWU7CiAgZm9yIChpbnQgaSA9IDA7IGkgPCAxMDsgaSsrKSBpZiAoYXJyW2ldID09IGZhbHNlKSBxID0gZmFsc2U7CiAgaWYgKHEgPT0gZmFsc2UpIHJldHVybiB0cnVlOwogIGVsc2UgcmV0dXJuIGZhbHNlOwp9CnZvaWQgRmlsbGluZyhib29sIGFycltdLCBsb25nIGEpIHsKICBpbnQgYjsKICB3aGlsZSAoYSA+IDApIHsKICAgIGIgPSBhICUgMTA7CiAgICBhcnJbYl0gPSAoYm9vbCkxOwogICAgYSA9IChhIC0gYikgLyAxMDsKICB9Cn0KaW50IG1haW4oKSB7CiAgbG9uZyBuLCBrOwogIGJvb2wgYXJyWzEwXTsKICB3aGlsZSAoY2luID4+IG4pIHsKICAgIGsgPSAwOwogICAgZm9yIChpbnQgaSA9IDA7IGkgPCAxMDsgaSsrKSBhcnJbaV0gPSAwOwogICAgd2hpbGUgKENoZWtpbmcoYXJyKSkgewogICAgICBrKys7CiAgICAgIEZpbGxpbmcoYXJyLCBrICogbik7CiAgICB9CiAgICBjb3V0IDw8IGsgPDwgJ1xuJzsKICB9Cn0=