use strict; chomp(my $s = <>); chomp(my $t = <>); my $c = 0; while ($s =~ /(\Q$t\E)/g) { $c++; } if ($c && (length($t) == 1 || $t =~ /^\.+$/)) { print("-1\n"); } else { print($c, "\n"); }