#!/usr/bin/env python3

__author__ = 'Wei Mu'

class Solution:
    def removeDuplicates(self, nums: List[int]) -> int:
        
        if len(nums) <= 2:
            return len(nums)
        
        drop_list = []
        
        for ind in range(2, len(nums)):
            if nums[ind] == nums[ind-2]:
                drop_list.append(ind)
        
        for i in drop_list[::-1]:
            nums.pop(i)
        
        return len(nums)
