Variable to store total elements which on dividing by 3 give remainder 0 , 1 and 2 respectively
int zero = ( int ) Math . floor ( ( double ) r / 3 ) - ( int ) Math . ceil ( ( double ) l / 3 ) + 1 ; int one = ( int ) Math . floor ( ( double ) ( r - 1 ) / 3 ) - ( int ) Math . ceil ( ( double ) ( l - 1 ) / 3 ) + 1 ; int two = ( int ) Math . floor ( ( double ) ( r - 2 ) / 3 ) - ( int ) Math . ceil ( ( double ) ( l - 2 ) / 3 ) + 1 ;