class Solution:
    def solve(self , a):
        # write code here
        i = 0
        while (i<len(a)):
            if a[i] != i:
                return i
            if i==len(a)-1:
                return i+1
            i+=1