#include using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; int answer = 0; for(int i=1; i<=N; i++){ string s = to_string(i); bool ok = false; for(auto c : s) ok |= c=='8'; answer += ok; } cout << answer << endl; }