while(line = readline()) {
const num = parseInt(line);
let count = 0;
for (let i = 1; i <= num; i++) {
if (isCludesSeven(i.toString()) || isSevenX(i)) {
count++;
}
}
print(count);
}
function isCludesSeven(str) {
return /[7]/.test(str);
}
function isSevenX(num) {
return num % 7 == 0;
}