fn main [ var lines := list_break_to_lines(read_lazy(h[0])); lines := list_flatten(lines); const x := len(lines[0]); const y := len(lines); var a := list_to_array([x, y], list_join(lines, "")); a := array_flatten(a); var found := 0; for j := 0 to y do [ for i := 0 to x do [ if a[i, j] <> 'X' then continue; for dx := -1 to 2 do [ for dy := -1 to 2 do [ var xx := i + dx; var yy := j + dy; for q := 0 to 3 do [ if xx < 0 or xx >= x or yy < 0 or yy >= y then goto cont; var str := "MAS"; if a[xx, yy] <> str[q] then goto cont; xx += dx; yy += dy; ] found += 1; cont: ] ] ] ] write(h[1], ntos(found) + nl); ]