using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray(); static string[] SList(long n) => Enumerable.Repeat(0, (int)n).Select(_ => ReadLine()).ToArray(); public static void Main() { Solve(); } static void Solve() { var n = NN; var map = SList(n); var ans = 0; for (var i = 0; i < n; ++i) { var a = 0; var d = 0; for (var j = 0; j < n; ++j) { if (map[i][j] == 'A') ++a; if (map[i][j] == '.') ++d; } if (a + 1 == n && d == 1) ++ans; } for (var j = 0; j < n; ++j) { var a = 0; var d = 0; for (var i = 0; i < n; ++i) { if (map[i][j] == 'A') ++a; if (map[i][j] == '.') ++d; } if (a + 1 == n && d == 1) ++ans; } { var a = 0; var d = 0; for (var i = 0; i < n; ++i) { if (map[i][i] == 'A') ++a; if (map[i][i] == '.') ++d; } if (a + 1 == n && d == 1) ++ans; } { var a = 0; var d = 0; for (var i = 0; i < n; ++i) { if (map[i][n - i - 1] == 'A') ++a; if (map[i][n - i - 1] == '.') ++d; } if (a + 1 == n && d == 1) ++ans; } WriteLine(ans); } }