Behaviors of quark matter and strange quark matter which exist in the first seconds of the early Universe in f(R) gravity are studied for Bianchi I and V universes. In this respect, we obtain exact solutions of the modified Einstein field equations by using anisotropy feature of Bianchi I and V space-times. In particular, we investigate exact f(R) functions for Bianchi I as the contribution of strange quark and quark matter. Also, we have concluded that quark matter may contribute to the early acceleration of the universe since quark matter behaves like phantom-type dark energy. Furthermore, obtained f(R) solutions represents early eras of the Universe since f(R) solutions for quark matter coincide with f(R) equations for inflation. From this point, we can reach the conclusion that quarks may be source of the early dark energy of the universe or source of little inflation due to their repulsive force.