states = ('q0', 'q1', 'q2')
start = 'q0'
accept = ('q0',)
s = input()
# start with the start state, use the transition function...
currentState = start
for currentLetter in s:
# transition function in here, can only use current input symbol and
# current state
# big 'ol if/elseif
if currentState == 'q0' and currentLetter == 'a':
currentState = 'q0'
elif currentState == 'q0' and currentLetter == 'b':
currentState = 'q1'
elif currentState == 'q1' and currentLetter == 'a':
currentState = 'q1'
elif currentState == 'q1' and currentLetter == 'b':
currentState = 'q2'
elif currentState == 'q2' and currentLetter == 'a':
currentState = 'q2'
elif currentState == 'q2' and currentLetter == 'b':
currentState = 'q0'
else: print('THIS SHOULD NOT HAPPEN')
# do we accept or not
doIAccept = False
for x in accept:
if currentState == x:
doIAccept = True
break