#include
#include
#include
#include
using namespace std;
int main() {
string str;
getline(cin, str);
char ch[30];
strcpy(ch, str.c_str());
int num = str.length();
int out[8];
int outCount = 0;
if (ch[num-1] == '0' || ch[num-1] == '2' || ch[num-1] == '4' || ch[num-1] == '6' || ch[num-1] == '8') {
out[outCount++] = 2;
int temp = 0;
for (int i = 0; i
temp += ch[i] - '0';
if (temp % 3 == 0)
out[outCount++] = 6;
temp = 0;
temp = (ch[num-2] - '0') * 10 + ch[num-1] - '0';
if (temp % 4 == 0)
out[outCount++] = 4;
temp = (ch[num-3] - '0') * 100+(ch[num-2] - '0') * 10 + ch[num-1] - '0';
if (temp % 8 == 0)
out[outCount++] = 8;
}
int total = 0;
for (int i = 0; i
total += ch[i] - '0';
}
if (total % 3 == 0)
out[outCount++] = 3;
if (total % 9 == 0)
out[outCount++] = 9;
if (ch[num-1] == '0' || ch[num-1] == '5')
out[outCount++] = 5;
total = 0;
if (num <= 3) {
if (num == 1) {
if (ch[0] == '7')
out[outCount++] = 7;
}
if (num == 2) {
if (((ch[0] - '0')*10 + (ch[1] - '0')) % 7 == 0)
out[outCount++] = 7;
}
if (num == 3) {
if (((ch[0] - '0')*100 + (ch[1] - '0') * 10 + (ch[2] - '0')) % 7 == 0)
out[outCount++] = 7;
}
}
else {
for (int i = num - 4; i>=0; i--) {
if (i == num - 4)
total = (ch[i] - '0') * 100 + (ch[i + 1] - '0') * 10 + (ch[i + 2] - '0') - (ch[i + 3] - '0') * 2;
else {
total += (ch[i] - '0') * 1000;
int temp1 = total % 10;
total /= 10;
total = total - temp1 * 2;
}
}
if (total % 7 == 0)
out[outCount++] = 7;
}
sort(out, out + outCount);
if (outCount>0) {
for (int i = 0; i
if (i == outCount - 1)
cout << out[i];
else
cout << out[i] << " ";
}
cout << endl;
}
else
cout << "none" << endl;
}