Snow has a string, and now he wants to use magic to shorten this string. Each time he casts a spell, he can eliminate three adjacent identical characters. But Snow finds it too time-consuming to cast the spell repeatedly, so he hopes you can help him calculate what the shortest form of the string will be after using magic any number of times.
Input a string, ensuring that it only contains lowercase letters, and the length of the string does not exceed $$$10^6$$$.
Output a string representing the shortest string after casting magic.If the entire string is eliminated, the output should be "NAN".
bcabaaabbccabcc
bcaccabcc
| Название |
|---|


