A movie consists of scenes shown in order. Scene features actor .
The final cut is called smooth if no two consecutive scenes feature the same actor.
The editor may delete at most one non-empty contiguous segment of scenes. The remaining scenes keep their relative order. The editor may also choose not to delete anything.
Find the minimum number of scenes that must be deleted to make the final cut smooth.
The input consists of two lines:
Delete scenes through . The remaining actor sequence is , which is smooth. Deleting fewer than three scenes cannot eliminate both repeated adjacent pairs with one contiguous deletion.
Delete scenes through . The remaining actor sequence is , which is smooth. Any contiguous deletion of at most three scenes leaves two equal actors next to each other.