#import<iostream>
using namespace std;
int n,i,j,A[21][21],nr_varfuri;
int main(){
cin>>n;
for (i=1; i<=n;i++) for (j=1;j<=n;j++) cin>>A[i][j];
for (i=1; i<=n;i++) for (j=1;j<=n;j++){
int c = A[i][j];
if (c > A[i][j-1] && c > A[i][j+1] && c > A[i+1][j] && c > A[i-1][j]){
nr_varfuri = nr_varfuri + 1;
}
}
cout<<nr_varfuri;
return 0;
}