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