#!/usr/bin/perl use strict; use warnings; my ($x, $y, $d) = split / /, <>; my $count = 0; if($y < $x) { ($x, $y) = ($y, $x); } if($d < $x) { $count = $d + 1; } elsif(($x <= $d)and($d <= $y)) { $count = $x + 1; } elsif($d <= $x + $y) { $count = $x + $y + 1 - $d; } print "$count\n"; exit;