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

const int p = 90007;
int main() {
	long long a;
	cin >> a;
	vector table(p + 1, 0);
	int now = 1;
	for(int i = 1; i < p; i++) {
		now *= 10;
		now %= p;
		table[now] = i;
	}
	long long m = a + 1;
	auto chk = [&m]() {
		if(m % 10 == 0) return false;
		auto s = to_string(m);
		reverse(s.begin(), s.end());
		long long x = stoll(s);
		return x % 90007 != 1;
	};
	while(!chk()) m += a;
	string res = to_string(m);
	reverse(res.begin(), res.end());
	m = stoll(res);
	for(int i = 0; i < p - 1 - table[m % p]; i++) res.push_back('0');
	cout << res << endl;
}