a, b, s = map(int, input().split()) aa = s - a bb = s - b c = 0 if aa == 0: print(s) else: if abs(aa) <= abs(bb) or (b == 1 and bb == 0): c += abs(aa) c += s print(c) else: c += abs(bb) t = c c += abs(aa) c += a print(min(c, t + s + a - 1))