package main import . "fmt" import . "strings" func main() { var n int Scan(&n) col:=make([]int,n) var ans,x,y int for i:=range col { var s string Scan(&s) if Count(s,"B")==0&&Count(s,".")==1 { ans++ } for k,r:=range s { e:=int(r)*int(r)*int(r) col[k]+=e if k==i { x+=e } if k==n-1-i { y+=e } } } q:=int('A')*int('A')*int('A')*(n-1)+ int('.')*int('.')*int('.') if x==q { ans++ } if y==q { ans++ } for _,c:=range col { if c==q { ans++ } } Println(ans) }