//Problem "Matrix"
//8th Internet Olympiad, season 2007-2008
//Problem Author:  Fedor Tsarev, tsarev@rain.ifmo.ru
//Solution Author: Vladimir Ulyantsev, ulyantsev@rain.ifmo.ru
//It is too slow O(n*m*(n+m))

import java.io.*;
import java.util.*;

public class matrix_vu_slow implements Runnable {
	final static String FILE = "matrix";
	
	public static void main(String[] args) {
		Locale.setDefault(Locale.US);
		new Thread(new matrix_vu_slow()).start();
	}
	
	BufferedReader in;
	PrintWriter out;
	StringTokenizer st;
	
	int nextInt() throws IOException {
		while (st == null || !st.hasMoreElements()) {
			st = new StringTokenizer(in.readLine());
		}
		return Integer.parseInt(st.nextToken());
	}
	
	public matrix_vu_slow() {
		try {
			in = new BufferedReader(new FileReader(FILE + ".in"));
			out = new PrintWriter(new File(FILE + ".out"));
			st = new StringTokenizer("");
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}
	
	public void run() {
		try {
			solve();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			out.close();
		}
	}
	
	public void solve() throws IOException {
		int n = nextInt();
		int m = nextInt();

		int[][] k = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				k[i][j] = nextInt();
			}
		}

		int ans = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
			 	boolean y = true;
				for (int l = 0; l < n; l++) {
					if (k[l][j] > k[i][j]) {
						y = false;
					}	
				}
				for (int l = 0; l < m; l++) {
					if (k[i][l] < k[i][j]) {
						y = false;
					}	
				}
				if (y) {
					ans++;
				}
			}
		}
		out.print(ans);
	}
	
}
