More formally, we're talking about finite automata: https://en.wikipedia.org/wiki/Deterministic_finite_automaton