Counter Function In Python Time Complexity