#include<bits/stdc++.h>
using namespace std;
char p[150];
void solve(char p[]) {
int sum = 0;
for (int i = 0; i < strlen(p); i++)sum = (sum * 10 + p[i] - '0') % 17;
if (sum == 0)cout << 1 << "\n";
else cout << 0 << "\n";
}
int main() {
while (cin >> p) {
if (strlen(p) == 1 && p[0] == '0')return 0;
solve(p);
}
return 0;
}