#include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; #define int long long #define double long double typedef vector VI; typedef pair pii; typedef vector VP; typedef vector VS; typedef priority_queue PQ; templatebool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } templatebool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } #define fore(i,a) for(auto &i:a) #define REP(i,n) for(int i=0;i, greater > q2; int N, ans; void dfs(int now) { if (now > N)return; if (now >= 100) { ans++; //cout << now << endl; } now *= 10; dfs(now); dfs(now + 3); dfs(now + 6); dfs(now + 9); } signed main() { cin.tie(0); ios::sync_with_stdio(false); cin >> N; dfs(3); dfs(6); dfs(9); eFOR(i, 10, 99) { if (i > N)break; if (i % 3 == 0)ans++; } cout << ans << endl; return 0; }