This leads to TLE because your update code runs in linear time instead of logarithmic.
In particular, the following condition
if (b >= i && e <= j and b==e)
ensures that update will be performed separately for each element in the interval. However, in order to get logarithmic update time you need to have a condition of the form
if (b >= i && e <= j)
HINT: to do this you need to modify the state stored in each node of the segment tree. You could keep track of the number of elements equal to 0 mod 3, 1 mod 3 and 2 mod 3.