#include <stdio.h>
int main(void) {
int i,ii,iii,iiii,iiiii,iiiiii,n,p = 0;
for(i = 1;i <= 6;i++){
for(ii = 1;ii <= 6;ii++){
for(iii = 1;iii <= 6;iii++){
for(iiii = 1;iiii <= 6;iiii++){
for(iiiii = 1; iiiii <= 6;iiiii++){
for(iiiiii = 1; iiiiii <= 6;iiiiii++){
n = i * 100000 + ii * 10000 + iii * 1000 + iiii * 100 + iiiii * 10 + iiiiii * 1;
if (n % 7 == 0 && n % 111111 != 0){
p = p + 1;
}
}
}
}
}
}
}
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgbWFpbih2b2lkKSB7CglpbnQgaSxpaSxpaWksaWlpaSxpaWlpaSxpaWlpaWksbixwID0gMDsKCWZvcihpID0gMTtpIDw9IDY7aSsrKXsKCQlmb3IoaWkgPSAxO2lpIDw9IDY7aWkrKyl7CgkJCWZvcihpaWkgPSAxO2lpaSA8PSA2O2lpaSsrKXsKCQkJCWZvcihpaWlpID0gMTtpaWlpIDw9IDY7aWlpaSsrKXsKCQkJCQlmb3IoaWlpaWkgPSAxOyBpaWlpaSA8PSA2O2lpaWlpKyspewoJCQkJCQlmb3IoaWlpaWlpID0gMTsgaWlpaWlpIDw9IDY7aWlpaWlpKyspewoJCQkJCQkJbiA9IGkgKiAxMDAwMDAgKyBpaSAqIDEwMDAwICsgaWlpICogMTAwMCArIGlpaWkgKiAxMDAgKyBpaWlpaSAqIDEwICsgaWlpaWlpICogMTsKCQkJCQkJCWlmIChuICUgNyA9PSAwICYmIG4gJSAxMTExMTEgIT0gMCl7CgkJCQkJCQkJcCA9IHAgKyAxOwoJCQkJCQkJfQoJCQkJCQl9CgkJCQkJfQoJCQkJfQoJCQl9CgkJfQoJfQoJcHJpbnRmKCIlZFxuIiwgcCk7CglyZXR1cm4gMDsKfQo=