#!/usr/bin/perl -w

use strict;
use v5.30;

chomp (my $line = <>);

my $traps;
for (1 .. 40) {
	$traps += () = $line =~ /\./g;
	say $traps;
	$line = '.' . $line . '.';
	my $nl = '';
	for my $i (0 .. length($line)-3) {
		my $p = substr($line, $i, 3);
		$nl .= ($p eq '^^.' || $p eq '.^^' || $p eq '^..' || $p eq '..^')
			? '^' : '.';
	}
	say "$_ $nl";
	$line = $nl;
}

