#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<string> stud(n);
  vector<int> sec(n, 0);
  vector<int> poss;
  int temp, pos, tempPos;
  for (int i = 0; i < n; i++) cin >> stud[i];
  for (int j = 0; j < m; j++) {
    pos = -1;
    temp = 0;
    for (int i = 0; i < n; i++) {
      if (stud[i][j] > temp) {
        pos = i;
        temp = stud[i][j];
      } else if (stud[i][j] == temp) {
        if (tempPos != temp) poss.clear();
        tempPos = temp;
        if (pos >= 0) poss.push_back(pos);
        pos = -2;
        poss.push_back(i);
        temp = stud[i][j];
      }
    }
    if (pos == -2) {
      for (int i = 0; i < poss.size(); i++) sec[poss[i]] = 1;
    } else if (pos != -1)
      sec[pos] = 1;
    poss.clear();
  }
  for (int i = 1; i < n; i++) sec[0] += sec[i];
  cout << sec[0] << endl;
  return 0;
}
