Counting multiples of 3 up to a given number I'm attempting a practice problem in Codeforces that requires you to find the number of multiples of 3 less than or equal to a given number. I have written the following code but it gives a TLE once the test case reaches the order of 108.

int x = Reader.nextInt();
int count = 0;

for(int i = 3; i&lt;=x; i++){
    if(i%3 == 0){
        count++;
    }
}
System.out.println(count);


Is there any way I can further optimize this code? The test cases max out at 109.
Use your brain, not brute force. How would you solve the problem if it were presented in a math test, and you couldn't use a computer?

Your solution requires \$O(x)\$ time; it should be possible in \$O(1)\$.