use strict; use warnings; my $in = ; chomp $in; my($start, $end) = split(' ', $in); for my $i ($start..$end) { if($i%3 == 0 or $i =~ m/3/){ print $i."\n"; } }