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