This is a homework problem. I've wrestled with it for quite awhile and can't come up with a valid solution. The problem is:
Find a regular grammar that generates each of the following languages: $$L = \{ w \in {a,b}^* \mid \text{na}(w) – \text{nb}(w) = 1 \mod 3 \} , $$
where $\text{na}(w)$ is the number of $a$s and $\text{nb}(w)$ the number of $b$'s occurring in $w$, respectively.
It seems as though a DFA can't accept this language since any difference of $a$'s and $b$'s resulting in 1 will be in the language, but that gives an infinite number of possibilities.
Any help pointing me in the right direction for this problem would be much appreciated.