p = [int(i) for i in input().split()]
l = len(p)
number = [i+1 for i in range(l)]
d = [bool(p[i]-number[i]) for i in range(l)]
d.append(True)
cnt = 0
i = 0
while i < l:
    if d[i] == False:
        cnt += 1
        if d[i+1] == False:
            i += 1
    i += 1

print(cnt)