import java.util.Scanner;
public class bj1100 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int i, j, total = 0;
String temp = "";
for(i = 0; i < 8; i++)
{
temp = scanner.next();
for(j = 0; j < 8; j++)
{
if(i % 2 == 0)//짝수 줄
{
if(j % 2 == 0 && temp.charAt(j) == 'F')//짝수 번
{
total++;
}
}
else//홀수 줄
{
if (j % 2 == 1 && temp.charAt(j) == 'F')//홀수 번
{
total++;
}
}
}
}
System.out.println(total);
scanner.close();
}
}