'use strict';
const input = require("fs").readFileSync("/dev/stdin", "utf8");
let l = [];
for (let i = 1; i <= input; i++) {
    for (let ii = 0; ii < Number(String(i).length); ii++) {
        let result = (function () {
            if (String(i).substr(ii, 1).match(/7|5|3/)) {
            } else {
                return 0;
            }
        })();
        if (result != 0) {
            l.push(0);
        }
    }
}
console.log(l.length);