#include #define rep(i,n) for (int i=0; i < (n); i++) using namespace std; using ll = long long; int ctoi(char x){ return x - '0'; } int solve1(int N, int ans){ for(int i=111; i<=N; i+=3){ string s = to_string(i); bool flg=true; for(int j=0; j=0){ if(s[t-1]=='9'){ ret*= 10; ct++; flg2 = true; }else{ break; } t--; } i += ret; if(flg2){ int y = 9; ct--; while(ct--){ y = y + y*10; } i -= y; } } return ans; } int main(){ ios::sync_with_stdio(false); int N; cin>>N; ll ans = 0; ll t=10; // 2桁の特殊処理 while(t<100){ int a = t%10; int b = (t/10)%t; if((a+b)%3==0){ ans ++; } if(t==N) break; t++; } // cout << solve1(N,ans) << endl; cout << solve2(N,ans) << endl; }