use strict; my $matsu = ; my @list = split(/ /,$matsu); if(@list[0] > @list[1]) { print 2 * (10 ** 9) - @list[1] - 1,"\n"; } else { print list[1] - 2,"\n"; }