# coding: UTF-8 import sys #sys.setrecursionlimit(n) import heapq import re import bisect import random import math import itertools from collections import defaultdict, deque from copy import deepcopy from decimal import * a, b, c = map(int, input().split()) count = 0 if a == 0: a += 1 b += 1 c += 1 if c == 1: count += a else: aa = abs(a - c) bb = abs(b - c) if aa > bb: count += bb count += min(aa + c, c - 1 + a) else: count += aa + c print(count)