// Arup Guha
// Solution to UF Contest Question: Golf Fine
// 1/30/2010

import java.util.*;

public class golf {
	
	final public static int SIZE = 10;
	
	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		
		char[][] grid = new char[SIZE][];
		
		// Read in the grid.
		for (int i=0; i<SIZE; i++) {
			String line = stdin.next();
			grid[i] = line.toCharArray();
		}
		
		// Find our starting location.
		int x=0,y=0;
		for (int i=0; i<SIZE; i++) {
			for (int j=0; j<SIZE; j++) {
				if (grid[i][j] == 's') {
					x = i;
					y = j;
					break;
				}
			}
		}
		
		// Fill our course with X's.
		floodfill(grid,x,y);
		
		// Print out our answers.
		System.out.println(countX(grid));
		
		int m = countM(grid);
		
		// Output regular case.
		if (m < 20)
		    System.out.println("$"+(50*countM(grid))+" 000");
		
		// This is because they are being very particular with the output format...
		// Really???
		else {
			
			// I'm being lazy here but there's only two special cases, I swear!
			if (m%20 > 1)
			    System.out.println("$"+(50*m/1000)+" "+((50*m)%1000)+" 000");
			else if (m%20 == 1)
				System.out.println("$"+(50*m/1000)+" 0"+((50*m)%1000)+" 000");
			else
				System.out.println("$"+(50*m/1000)+" 000 000");
		}
	}
	
	// Floodfills starting from spot (x,y) all of the contiguous
	// locations to s that have a d.
	public static void floodfill(char[][] grid, int x, int y) {
		
		// Mark this spot
		grid[x][y] = 'X';
		
		// Run through each adjacent square.
		for (int i=-1; i<2; i++) {
			for (int j=-1; j<2; j++)
				
				// Only fill it if it's inbounds and part of the course(d).
				if (inbounds(x+i,y+j) && grid[x+i][y+j]=='d')
					floodfill(grid,x+i,y+j);
		}
	}
	
	// Returns true iff x and y are valid 
	public static boolean inbounds(int x, int y) {
		return x >= 0 && x < SIZE && y >= 0 && y < SIZE;
	}
	
	// Returns the number of occurences of 'X' in grid.
	public static int countX(char[][] grid) {
		
		int count = 0;
		
		// Just go through each square and count...
		for (int i=0; i<SIZE; i++)
			for (int j=0; j<SIZE; j++)
				if (grid[i][j] == 'X')
					count++;
		return count;
	}
	
	// Returns the number of occurences of 'm' that are adjacent to
	// X's in grid.
	public static int countM(char[][] grid) {
		int count = 0;
		
		// Go through each square and count the m's we want to.
		for (int i=0; i<10; i++)
			for (int j=0; j<10; j++)
				if (grid[i][j] == 'm' && adjacentX(grid,i,j))
					count++;
		return count;
	}
	
	// Returns true if there is an 'X' adjacent to the location (x,y)
	// in grid.
	public static boolean adjacentX(char[][] grid, int x, int y) {
		
		// Go through all adjacent locations looking for an 'X'.
		for (int i=-1; i<2; i++) {
			for (int j=-1; j<2; j++)
				if (inbounds(x+i,y+j) && grid[x+i][y+j]=='X')
					return true;
		}
		
		// Didn't find one.
		return false;
	}
}