#include <bits/stdc++.h>
using namespace std;
int size_n, size_m;
set<int> result;
vector<char> marks(0);
vector<string> mrk(0);
int main() {
  int ii, jj;
  string str;
  cin >> size_n >> size_m;
  marks.resize(size_m);
  mrk.resize(size_n);
  cin.ignore();
  for (ii = 0; ii < size_m; ii++) marks[ii] = 'n';
  for (ii = 0; ii < size_n; ii++) {
    getline(cin, str);
    mrk[ii] = str;
    for (jj = 0; jj < size_m; jj++) {
      if ((marks[jj] == 'n') || (str[jj] >= marks[jj])) marks[jj] = str[jj];
    }
  }
  for (ii = 0; ii < size_m; ii++) {
    for (jj = 0; jj < size_n; jj++) {
      if (mrk[jj][ii] == marks[ii]) result.insert(jj);
    }
  }
  cout << result.size() << endl;
  return 0;
}
