import sys s = sys.stdin.readline() nums = [int(_) for _ in s.strip().split(',')] if len(set(nums)) == len(nums): print(0) else: nums.sort() count = 0 for i in range(1,len(nums)): if nums[i] == nums[i-1]: nums[i]+=1 count += 1 elif nums[i-1]>nums[i]: count += nums[i-1]+1-nums[i] nums[i] = nums[i-1]+1 print(count)ac