class Solution:
def addMinimum(self, word: str) -> int:
word2 = []
if word[0] == 'a':
operations = 0
elif word[0] == 'b':
operations = 1
word2.append('a')
elif word[0] == 'c':
operations = 2
word2.append('a')
word2.append('b')
for i in word:
if len(word2) == 0:
word2.append(i)
continue
p = word2[-1]
if (p == 'a' and i == 'b') or (p == 'b' and i == 'c') or (p == 'c' and i == 'a'):
word2.append(i)
continue
elif p == i:
word2.append(i)
operations += 2
elif (p == 'a' and i == 'c') or (p == 'b' and i == 'a') or (p == 'c' and i == 'b'):
word2.append(i)
operations += 1
if word2[-1] == 'a':
operations += 2
elif word2[-1] == 'b':
operations += 1
return operations
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}