fn main [ const n_steps := 64; var lines := list_break_to_lines(read_lazy(h[0])); const x := len(lines[0]); const y := len(lines); var a := list_to_array([x, y], list_join(lines, "")); var start_x := 0; var start_y := 0; for steps := 0 to n_steps do [ var a2 := a; for j := 0 to y do [ for i := 0 to x do [ if a[i, j] = 'S' then [ if steps = 0 then [ start_x := i; start_y := j; ] for d in [ [0,-1], [-1,0], [0,1], [1,0] ] do [ var dx := d[0]; var dy := d[1]; if i + dx < 0 or i + dx >= x or j + dy < 0 or j + dy >= y then continue; if a[i + dx, j + dy] = '.' then a2[i + dx, j + dy] := 'S'; ] ] ] ] a := a2; ] var sum := 0; for i := 0 to x do [ for j := 0 to y do [ if a[i, j] = 'S' and not (i xor j xor start_x xor start_y xor n_steps) bt 0 then sum += 1; ] ] write(h[1], ntos(sum) + nl); ]