<p>You are given a <strong>0-indexed</strong> string <code>word</code>.</p>

<p>In one operation, you can pick any index <code>i</code> of <code>word</code> and change <code>word[i]</code> to any lowercase English letter.</p>

<p>Return <em>the <strong>minimum</strong> number of operations needed to remove all adjacent <strong>almost-equal</strong> characters from</em> <code>word</code>.</p>

<p>Two characters <code>a</code> and <code>b</code> are <strong>almost-equal</strong> if <code>a == b</code> or <code>a</code> and <code>b</code> are adjacent in the alphabet.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> word = &quot;aaaaa&quot;
<strong>Output:</strong> 2
<strong>Explanation:</strong> We can change word into &quot;a<strong><u>c</u></strong>a<u><strong>c</strong></u>a&quot; which does not have any adjacent almost-equal characters.
It can be shown that the minimum number of operations needed to remove all adjacent almost-equal characters from word is 2.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> word = &quot;abddez&quot;
<strong>Output:</strong> 2
<strong>Explanation:</strong> We can change word into &quot;<strong><u>y</u></strong>bd<u><strong>o</strong></u>ez&quot; which does not have any adjacent almost-equal characters.
It can be shown that the minimum number of operations needed to remove all adjacent almost-equal characters from word is 2.</pre>

<p><strong class="example">Example 3:</strong></p>

<pre>
<strong>Input:</strong> word = &quot;zyxyxyz&quot;
<strong>Output:</strong> 3
<strong>Explanation:</strong> We can change word into &quot;z<u><strong>a</strong></u>x<u><strong>a</strong></u>x<strong><u>a</u></strong>z&quot; which does not have any adjacent almost-equal characters. 
It can be shown that the minimum number of operations needed to remove all adjacent almost-equal characters from word is 3.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= word.length &lt;= 100</code></li>
	<li><code>word</code> consists only of lowercase English letters.</li>
</ul>

class Solution:
    def removeAlmostEqualCharacters(self, w: str) -> int:
        """
        - if adjacent characters are almost-equal, we must change one of the characters
            - change either to any character a - z
        - better to change right character in order to prevent another change after
        - dp[ : i] - minimum op for w[ : i]
        """
        res = i = 0
        while i < len(w) - 1:
            if i + 1 < len(w) and abs(ord(w[i]) - ord(w[i + 1])) <= 1:
                res += 1
                i += 2
            else:
                i += 1
        return res

40