my ($n, $m) = split /\s/, <>; my @fib = (0, 1); for (my $i = 2; $i < $n; $i++) { push @fib, ($fib[$i - 1] + $fib[$i - 2]) % $m; } print $fib[$n - 1];