function Main(s) {
  var s = s.split("\n");
  const n = +s[0];
  for(var i = 0; i < n; i++){
    s[i] = s[i+1] + s[i+1];
  }
  for(; i < n * 2; i++){
    s[i] = s[i-n];
  }
  var ans = 0;
  for(i = 0; i < n; i++)
  for(var j = 0; j < n; j++){
    ans += f(i, j);
  }
  console.log(ans);
  
  function f(a, b){
    for(var i = a;i < a + n; i++)
    for(var j = b;j < b + n; j++){
      if(i - a === j - b)continue;
      if(s[i][j] !== s[j][i])return 0;
    }
    return 1;
  }
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));