($_,$s,$t)=<>;for$j(!/ /..$'){map+($d{$_,$j})=$_?$j?sort{$a-$b}$d{$_-1,$j-1}+(vec($s,$_-1,8)!=vec($t,$j-1,8)),$d{$_-1,$j}+1,$d{$_,$j-1}+1:$_:$j,0..$_};print$d{$_+0,$'+0}