#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory.h>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define FORI(i,n) for(int i=0; i<n; ++i)
#define FORIR(i,n) for(int i=(n)-1; i>=0; --i)
#define MP(a,b) make_pair(a,b)
#define ALL(L) (L).begin(),(L).end()
#define ALLR(L) (L).rbegin(),(L).rend()
#define SZ(L) (L).size()
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define SORTED_PAIR(a,b) MIN(a,b),MAX(a,b)
#define INF (1<<29)
#define EPS (1e-9)

typedef unsigned int uint;
typedef unsigned long long ull;
typedef signed long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pii;

int main() {
  int n,m,s=0;
  cin >> n >> m;
  vector<vector<int> > mk(n, vector<int>(m));
  vector<int> mx(m, 0);
  FORI(i,n){
    string s;
    cin >> s;
    FORI(j,m){
      mk[i][j] = s[j] - '0';
      mx[j] = max(mx[j], mk[i][j]);
    }
  }
  FORI(i,n){
    FORI(j,m){
      if(mk[i][j] == mx[j]) {
        s++;
        break;
      }
    }
  }
  cout << s << endl;
}


#include <cstdlib>
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main(int argc, char *argv[])
{int a,b,x,i,max=0;
cin>>a>>b;
string s[a]; vector <int> v(a);
for (i=0;i<a;i++) {cin>>s[i];}
for (i=0;i<b;i++) {
    for (x=0;x<a;x++) {if (max<s[x][i]) {max=s[x][i];} }
    for (x=0;x<a;x++) {if (max==s[x][i]){v[x]=1;}}
    max=0;
                  }
  i=0;
  for (x=0;x<a;x++) {i+=v[x]; }
  cout<<i<<endl;

    return EXIT_SUCCESS;
}


#include <cstdlib>
#include <iostream>
#include <string >
#include <vector>
using namespace std;

int main(int argc, char *argv[])
{int o,u; cin>>o>>u;
    vector <string> a(100); int max=-1,x=0;
vector <bool> z(o+1);
for (int i=0;i<o;i++) {cin>>a[i];}
int k= a[0].size();
for (int i=0;i<o;i++) {
    for (int y=0;y<k+1;y++) {if (max<a[y][i]) {max=a[y][i];}}
    for (int n=0;n<o;n++) {if (max==a[n][i]) {z[n]=true;}} max=-1;
    }for (int i=0;i<o;i++) {if (z.at(i)){x++;}}
    cout<<x;

    return EXIT_SUCCESS;
}


#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;

int main(int argc, char *argv[])
{int a,z=0,x=0,i; string s;
 cin>>a>>s;
 for(i=0;i<a;i++) {if ((s[i]=='4')||(s[i]=='7')) {z++;}   }
 if (z!=a) {cout<<"NO"<<endl;}
 else {for (i=0;i<a/2;i++) {x+=s[i];}
       z=0;
       for (i=a/2;i<a;i++) {z+=s[i];}

       if (z==x) {cout<<"YES"<<endl;}
       else {cout<<"NO"<<endl;}

      }
    system("PAUSE");
    return EXIT_SUCCESS;
}


//============================================================================
// Copyright   : Amr
//============================================================================
#include <iostream>
#include <fstream>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
using namespace std;

#define oo (1<<30)
#define sz(v) (int)v.size()
#define pb push_back
#define mp make_pair
#define ppc(x) __builtin_popcount(x)
#define mem(s,v) memset(s,v,sizeof(s))

int fun(long long int x, int n) {

    int ar[100];
    memset(ar, -1, sizeof(ar));
    int i = 99;
    while (x) {
        ar[i] = x % 10;
        x /= 10;
        i--;
    }

    long long int t = 0;
    i = 0;
    int K = 1;
    while (K <= n && i <= 99) {
        if (ar[i] != -1) {
            t *= 10;
            t += ar[i];
            K++;
        }
        i++;
    }

    return t;
}
int main() {
    int x,y;
    cin>>x>>y;
    string s[x];
    for(int i=0;i<x;i++)
        cin>>s[i];
    map<int,bool> m;
    for(int i=0;i<y;i++){
        int mx=-9999;
        for(int z=0;z<x;z++){
            mx=max(mx,(s[z][i]-'0') );
        }
        for(int z=0;z<x;z++){
            if(mx==(s[z][i]-'0'))
                m[z]=1;
        }

    }

    cout<<m.size()<<endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <memory.h>
using namespace std;

const int MAXN = 1000 + 7;
const int INF = 1e9;
const double EPS = 1e-9;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pt;

#define x first
#define y second
#define check(x, y) ((x) < 5 && (x) >= 0 && (y) < 5 && (y) >= 0 && !used[(x)][(y)])

const int dx[] = {2, 2, 1, -1, -2, -2, -1, 1};
const int dy[] = {1, -1, -2, -2, -1, 1, 2, 2};

int gcd(int a, int b)
{
	if (!b)
		return a;
	return gcd(b, a % b);
}

int a[MAXN][MAXN];
void solve()
{
	set<int> ans;
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; ++i)
		for(int j = 0; j < m; ++j)
		{
			char c;
			cin >> c;
			a[i][j] = c - '0';
		}
	for(int i = 0; i < n; ++i)
	{
		int mx = 0;
		set<int> best;
		for(int j = 0; j < m; ++j)
			if (a[j][i] > mx)
			{
				best.clear();
				best.insert(j);
				mx = a[j][i];
			}
			else
				if (a[j][i] == mx)
					best.insert(j);
		for(set<int>::iterator it = best.begin(); it != best.end(); ++it)
			ans.insert(*it);
	}
	cout << ans.size() << endl;
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	solve();
	return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <memory.h>
using namespace std;

const int MAXN = 1000 + 7;
const int INF = 1e9;
const double EPS = 1e-9;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pt;

#define x first
#define y second
#define check(x, y) ((x) < 5 && (x) >= 0 && (y) < 5 && (y) >= 0 && !used[(x)][(y)])

const int dx[] = {2, 2, 1, -1, -2, -2, -1, 1};
const int dy[] = {1, -1, -2, -2, -1, 1, 2, 2};

int gcd(int a, int b)
{
	if (!b)
		return a;
	return gcd(b, a % b);
}

int a[MAXN][MAXN];
void solve()
{
	set<int> ans;
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; ++i)
		for(int j = 0; j < m; ++j)
		{
			char c;
			cin >> c;
			a[i][j] = c - '0';
		}
	for(int i = 0; i < m; ++i)
	{
		int mx = 0;
		set<int> best;
		for(int j = 0; j < n; ++j)
			if (a[j][i] > mx)
			{
				best.clear();
				best.insert(j);
				mx = a[j][i];
			}
			else
				if (a[j][i] == mx)
					best.insert(j);
		for(set<int>::iterator it = best.begin(); it != best.end(); ++it)
			ans.insert(*it);
	}
	cout << ans.size() << endl;
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	solve();
	return 0;
}


#include<iostream>

using namespace std;

int INT (char R , int c );

int main(){
	char R;
	int n,m,c;
	cin>>n>>m;
	string list[n];
	int success[n];
	int Marks[n][m];
	for(int i=0 ; i<n ; i++)
		cin>>list[i];
	// change from string matrix to int matrix of marks
	for(int i=0 ; i<n ; i++)
	{
		for(int j=0 ; j<m ; j++)
		{
			R=list[i][j];
			Marks[i][j]=INT(R,c);
		}
	}
	for(int i=0 ; i<n ; i++)
		success[i]=0;

	// Get the max for each subject
	for(int i=0 ; i<m ; i++)
	{
		int max=Marks[0][i];
		for(int j=0 ; j<n ; j++)
		{
			if(Marks[j][i]>max)
				max=Marks[j][i];
		}
		for(int j=0 ; j<n ; j++)
		{
			if(Marks[i][j]==max)
				success[j]+=1;
		}

	}
	//check how many success
	int h=0;
	for(int i=0 ; i<n ; i++)
	{
		if(success[i]>0)
			h++;
	}
	cout<<h<<endl;

	//cout
	/*for(int i=0 ; i<n ; i++)
	{
		for(int j=0 ; j<m ; j++)
		{
			cout<<Marks[i][j]<<" ";
		}
		cout<<endl;
	}*/

	return 0;
}
int INT (char R , int c )
{
	if(R=='1')
		c=1;
	if(R=='2')
		c=2;
	if(R=='3')
		c=3;
	if(R=='4')
		c=4;
	if(R=='5')
		c=5;
	if(R=='6')
		c=6;
	if(R=='7')
		c=7;
	if(R=='8')
		c=8;
	if(R=='9')
		c=9;
	if(R=='0')
		c=0;

	return c;
}


#include<iostream>

using namespace std;

int main(){
	char R;
	int n,m,c;
	cin>>n>>m;
	string list[n];
	int success[n];
	int Marks[n][m];

	//cin
	for(int i=0 ; i<n ; i++)
		cin>>list[i];

	// change from string matrix to int matrix of marks
	for(int i=0 ; i<n ; i++)
	{
		for(int j=0 ; j<m ; j++)
		{
			Marks[i][j]=list[i][j]-'0';
		}
	}
	for(int i=0 ; i<n ; i++)
		success[i]=0;

	// Get the max for each subject
	for(int i=0 ; i<m ; i++)
	{
		int max=Marks[0][i];
		for(int j=0 ; j<n ; j++)
		{
			if(Marks[j][i]>max)
				max=Marks[j][i];
		}
		for(int j=0 ; j<n ; j++)
		{
			if(Marks[j][i]==max)
				success[j]+=1;
		}
	}

	//check how many success
	int h=0;
	for(int i=0 ; i<n ; i++)
	{
		if(success[i]>0)
			h++;
	}
	cout<<h<<endl;

	return 0;
}


#include<iostream>

using namespace std;

int INT (char R , int c );

int main(){
	char R;
	int n,m,c;
	cin>>n>>m;
	string list[n];
	int success[n];
	int Marks[n][m];

	//cin
	for(int i=0 ; i<n ; i++)
		cin>>list[i];

	// change from string matrix to int matrix of marks
	for(int i=0 ; i<n ; i++)
	{
		for(int j=0 ; j<m ; j++)
		{
			R=list[i][j];
			Marks[i][j]=INT(R,c);
		}
	}
	for(int i=0 ; i<n ; i++)
		success[i]=0;

	// Get the max for each subject
	for(int i=0 ; i<m ; i++)
	{
		int max=Marks[0][i];
		for(int j=0 ; j<n ; j++)
		{
			if(Marks[j][i]>max)
				max=Marks[j][i];
		}
		for(int j=0 ; j<n ; j++)
		{
			if(Marks[j][i]==max)
				success[j]+=1;
		}
	}

	//check how many success
	int h=0;
	for(int i=0 ; i<n ; i++)
	{
		if(success[i]>0)
			h++;
	}
	cout<<h<<endl;

	return 0;
}
int INT (char R , int c )
{
	if(R=='1')
		c=1;
	if(R=='2')
		c=2;
	if(R=='3')
		c=3;
	if(R=='4')
		c=4;
	if(R=='5')
		c=5;
	if(R=='6')
		c=6;
	if(R=='7')
		c=7;
	if(R=='8')
		c=8;
	if(R=='9')
		c=9;
	if(R=='0')
		c=0;

	return c;
}


#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;

int suc[1000],t;
int main()
{
    int a,b;
    char n[1000][1000],max;
    scanf("%d%d",&a,&b);
    for(int i=0; i<a; i++)
    {
        scanf("%s",&n[i]);
    }
    for(int i=0; i<b; i++)
    {
        max=-1;
        for(int k=0; k<a; k++)
        {
            if(max < n[k][i])
                max=n[k][i];

            }
            //printf("%c",max);
        for(int k=0; k<a; k++)
            {
                if(max == n[k][i])
                    suc[k]++;
        }
    }

    for(int i=0;i<1000;i++)
        if(suc[i]!=0)
            t++;

    printf("%d",t);
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    size_t n, m;
    cin >> n >> m;
    vector<string> marks(n);
    for (size_t i = 0; i < n; ++i)
    {
        cin >> marks[i];
    }
    vector<bool> successful(n, false);
    for (size_t subject = 0; subject < m; ++subject)
    {
        char best = '0';
        for (size_t i = 0; i < n; ++i)
        {
            if (marks[i][subject] > best)
            {
                best = marks[i][subject];
            }
        }
        for (size_t i = 0; i < n; ++i)
        {
            if (marks[i][subject] == best)
            {
                successful[i] = true;
            }
        }
    }
    cout << count(successful.begin(), successful.end(), true);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
void count(){
    #ifndef ONLINE_JUDGE
        freopen ("input.txt", "r", stdin);
    #endif
}
int main(){
    //count();
    int n, m;
    cin >> n >> m;
    string s[n];
    char a[m];
    for(int i=0; i<m; ++i){
        a[i] = '1';
    }
    for(int i=0; i<n; ++i){
        cin >> s[i];
        for(int j=0; j<m; ++j){
            if(s[i][j] > a[j]){
                a[j] = s[i][j];
            }
        }
    }
    int b[101] = {false};
    for(int i=0; i<n; ++i){
        for(int j=0; j<m; ++j){
            if(s[i][j] == a[j]){
                b[i] ++;
            }
        }
    }
    int ans = 0;
    for(int i=0; i<n; ++i){
        if(b[i] > 0) ans ++;
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
void count(){
    #ifndef ONLINE_JUDGE
        freopen ("input.txt", "r", stdin);
    #endif
}
int main(){
    //count();
    int n, m;
    cin >> n >> m;
    string s[n];
    char a[m];
    for(int i=0; i<m; ++i){
        a[i] = '1';
    }
    for(int i=0; i<n; ++i){
        cin >> s[i];
        for(int j=0; j<m; ++j){
            if(s[i][j] > a[j]){
                a[j] = s[i][j];
            }
        }
    }
    int b[101] = {false};
    for(int i=0; i<n; ++i){
        for(int j=0; j<m; ++j){
            if(s[i][j] == a[j]){
                b[i] ++;
            }
        }
    }
    int ans = 0;
    for(int i=0; i<m; ++i){
        if(b[i] > 0) ans ++;
    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <string>
#include <map>

using namespace std;

int main() {
   /// freopen("test.in", "r", stdin); freopen("test.out", "w", stdout);
    ios::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    cin.get();
    vector<string> grades(n);
    for (int i = 0; i < n; i++) {
        getline(cin, grades[i]);
        //cout << grades[i] << "\n";
    }

    vector<bool> successful(n);
    for (int i = 0; i < m; i++) {
        bool ok = false;
        for (char c = '9';c > '0'; c--) {
            for (int j = 0; j < n; j++) {
                if (grades[j][i] == c) {
                    ok = true;
           //         cout << j << "\n";
                    successful[j] = 1;
                }
            }

            if (ok) break;
        }
    }

    cout << count(successful.begin(), successful.end(), true);
    return 0;
}


#include <cstdio>
#include <algorithm>

char marks_[100][101], maxima_[100];

int main() {
  int n, m; std::scanf("%d%d", &n,& m);
  for (int i = 0; i < n; ++i) {
    std::scanf("%s", marks_[i]);
  }

  for (int j = 0; j < m; ++j) {
    for (int i = 0; i < n; ++i) {
      maxima_[j] = std::max(marks_[i][j], maxima_[j]);
    }
  }

  int count = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (marks_[i][j] != maxima_[j]) continue;

      ++count;
      break;
    }
  }
  std::printf("%d\n", count);
  return 0;
}


#include<iostream>
#include<algorithm>
#include<stdio.h>

#define pi 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998

using namespace std;

int gcd(int a, int b){
    return (b == 0 ? a : gcd(b, a % b));
}

int lcm(int a,int b){
	int temp = gcd(a,b);
	return temp? (a*b/temp) : 0 ;
}

char a[100][100];
int Max[100];

int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=0 ; i<n ; i++)
		for(int j=0 ; j<m ; j++){
			scanf(" %c",&a[i][j]);
			if(a[i][j]>Max[j])
				Max[j]=a[i][j];
		}
	int count=0;
	for(int i=0 ; i<n ; i++)
		for(int j=0 ; j<m ; j++)
			if(a[i][j]==Max[j]){
				count++;
				break;
			}
	printf("%d\n",count);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vbb;
#define all(X) (X).begin(), (X).end()

int main() {
	//freopen("in", "r", stdin);
	int n, m;
	char a;
	cin >> n >> m;
	vvi v(n,vi(m,0));
	set<int> s;
	for(int i=0; i<n; i++) for(int j=0; j<m; j++) {
		cin >> a;
		v[i][j] = a;
	}
	for(int j=0; j<m; j++){
		vi mm(1,0);
		int ind = 0;
		for(int i=1; i<n; i++)
			if(v[i][j] > v[ind][j]) mm.clear(), mm.push_back(i), ind = i;
			else if(v[i][j] == v[ind][j]) mm.push_back(i);
		for(auto x: mm)s.insert(x);
	}
	cout << s.size();
	return 0;
}


#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
    int n , s  , sum=0;
    cin >> n >> s ;
    string str[n];
    for (int i = 0 ; i<n ; i++ )
       cin >> str[i];
    for (int f = 0 ; f<n ; f++ ){
            int c=0 , check=0;
       for (int i = 0 ; i<s ; i++ ){
            c=0;
           for (int j = 0 ; j<n ; j++) {
            if (str[f][i]>=str[j][i]) c++;
            else break ;
        }
        if (c == n) {sum++; check = 1 ; break;}
    }

}
    cout<<sum;
}


#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {

    int nStudent, nSubject;
    cin >> nStudent >> nSubject;

    vector<string> marks(nStudent);
    vector<bool> hasBest(nStudent);

    for (int i = 0; i < nStudent; i++) {
        cin >> marks[i];
    }

    for (int j = 0; j < nSubject; j++) {
        char best = '0';
        for (int i = 0; i < nStudent; i++) {
            best = max(best, marks[i][j]);
        }
        for (int i = 0; i < nStudent; i++) {
            if (best == marks[i][j]) {
                hasBest[i] = true;
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < nStudent; i++) {
        if (hasBest[i]) {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){
    int n,m,count=0;
    cin>>n>>m;
    getchar();
    int a[n][m],max[m];
    for(int i=0;i<m;i++)max[i]=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            scanf("%1d",&a[i][j]);
            max[j]<a[i][j]?max[j]=a[i][j]:max[j];
        }
        getchar();
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(a[i][j]>=max[j]){
                count++;
                break;
            }
        }
    }
    cout<<count<<endl;
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){
    int n,m,count=0;
    cin>>n>>m;
    getchar();
    int a[n][m],max[m];
    for(int i=0;i<m;i++)max[i]=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            scanf("%1d",&a[i][j]);
            max[j]<a[i][j]?max[j]=a[i][j]:max[j];
        }
        getchar();
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(a[i][j]>=max[j]){
                count++;
                break;
            }
        }
    }
    cout<<count<<endl;
    return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int n,m,i,j,success[102];
char a[102][102];

scanf("%d %d",&n,&m);
for(i=0;i<n;i++)
scanf("%s",a[i]);

 for(j=0;j<m;j++)
{
 char best=0;
 for(i=0;i<n;i++)
 if(best<a[i][j])
 best=a[i][j];
for(i=0;i<n;i++)
{
 if(best==a[i][j])
 success[i]=1;
}
}
int c=0;
for(i=0;i<n;i++)
c+=success[i];
printf("%d",c);
return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int n,m,i,j,success[102];
char a[102][102];

scanf("%d %d",&n,&m);
for(i=0;i<n;i++)
scanf("%s",a[i]);

for(j=0;j<m;j++)
{
 char best=0;
 for(i=0;i<n;i++)
 if(best<a[i][j])
 best=a[i][j];
for(i=0;i<n;i++)
{
 if(best==a[i][j])
 success[i]=1;
}
}
int c=0;
for(i=0;i<n;i++)
c+=success[i];
printf("%d",c);
return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define sz(c) (int)c.size()

char v[101][101];

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            cin >> v[i][j];
    set<int> s;
    for (int i = 0; i < m; i++) {
        char MX = '0' - 1;
        for (int j = 0; j < n; j++) {
            MX = max(MX, v[j][i]);
        }
        for (int j = 0; j < n; j++) {
            if (v[j][i] == MX) s.insert(j);
        }
    }
    cout << sz(s) << endl;
}


#include <iostream>
#include <stdio.h>
#include <vector>
#include <set>
#include <cstdlib>
#include <math.h>
#include <string>
#include <map>
#include <algorithm>
#include <unordered_set>
using namespace std;
int main()
{
    char arr[101][101];
    int n,m;
    cin>>n>>m;
    vector<string>mx(m);
    vector<string>ss(n);
    for(int i=0;i<n;i++)
    {
        string str;
        cin>>str;
        ss[i]=str;
        for(int j=0;j<m;j++)
        {
            mx[j].push_back(str[j]);
        }
    }
    vector<int>v(n);
    for(int i=0;i<m;i++)
    {
        char c=*max_element(mx[i].begin(),mx[i].end());
        for(int j=0;j<n;j++)
        {
            if(ss[j][i]==c)
            {
                v[j]++;
            }
        }
    }
    int tot=0;
    for(int i=0;i<n;i++)
    {
        if(v[i]>0)
        {
            tot++;
        }
    }
    cout<<tot<<endl;
    }


#include <iostream>
#include <string>

using namespace std;

int main()
{
    int n,m,arr[110]={0},c=0;
    char grade[110][110]={0},maxx[110]= {0};
    bool check[110]= {true};
    cin>>n>>m;
    for (int i=0; i<n; i++)
    {
        for (int j=0; j<m; j++)
        {
            cin>>grade[i][j];
        }
    }
    for (int i=0; i<m; i++)
    {
        for (int j=0; j<n; j++)
        {
            for (int k=0; k<n; k++)
            {
                if (grade[j][i]>grade[k][i]&&grade[j][i]>maxx[i])
                {
                    maxx[i]=grade[j][i];
                }
                else if (grade[j][i]<grade[k][i]&&grade[k][i]>maxx[i])
                {
                    maxx[i]=grade[k][i];
                }
            }
            for (int u=0; u<n; u++)
            {
                if (grade[u][i]>=maxx[i])
                {
                    arr[u]++;
                }
            }
        }
    }
    for (int i=0; i<n; i++)
    {
        if (arr[i]>0)
        {
            c++;
        }
    }
    cout<<c<<endl;
    return 0;
}


#include <iostream>
#include <string>

using namespace std;

int main()
{
    int n,m,arr[110]= {0},c=0;
    char grade[110][110],maxx[110]= {0};
    bool check[110]= {true};
    cin>>n>>m;
    for (int i=0; i<n; i++)
    {
        for (int j=0; j<m; j++)
        {
            cin>>grade[i][j];
        }
    }
    for (int i=0; i<m; i++)
    {
        for (int j=0; j<n; j++)
        {
            for (int k=j+1; k<n; k++)
            {
                if (grade[j][i]>=grade[n][i]&&grade[j][i]>=maxx[i])
                {
                    maxx[i]=grade[j][i];
                }
            }
            for (int u=0; u<n; u++)
            {
                if (grade[u][i]>=maxx[i])
                {
                    arr[u]++;
                }
            }
        }
    }
    for (int i=0; i<n; i++)
    {
        if (arr[i]>0)
        {
            c++;
        }
    }
    cout<<c<<endl;
    return 0;
}


//4034103   Jul 7, 2013 1:39:50 PM	fuwutu	 152A - Marks	 GNU C++0x	Accepted	15 ms	100 KB
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    size_t n, m;
    cin >> n >> m;
    vector<string> marks(n);
    for (size_t i = 0; i < n; ++i)
    {
        cin >> marks[i];
    }
    vector<bool> successful(n, false);
    for (size_t subject = 0; subject < m; ++subject)
    {
        char best = '0';
        for (size_t i = 0; i < n; ++i)
        {
            if (marks[i][subject] > best)
            {
                best = marks[i][subject];
            }
        }
        for (size_t i = 0; i < n; ++i)
        {
            if (marks[i][subject] == best)
            {
                successful[i] = true;
            }
        }
    }
    cout << count(successful.begin(), successful.end(), true);
    return 0;
}


/*
ID: azret.k1
PROG:
LANG: C++11
*/

/*
 * Author: Kenzhaliev Azret
 * E-Mail: azret.kenzhaliev@gmail.com
 */

#include <bits/stdc++.h>

#include <iostream>
#include <fstream>
#include <algorithm>
#include <utility>
#include <cmath>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <vector>
#include <deque>
#include <queue>

using namespace std;

#define ACMP ifstream cin("input.txt"); ofstream cout("output.txt");
#define USACO ifstream cin(""); ofstream cout("");

#define pb push_back
#define pf push_front
#define fs first
#define sc second
#define mp make_pair

#define CLR(a) memset((a), 0, sizeof((a)))

typedef unsigned long long int ull;
typedef long long int ll;

typedef pair<int,int> pii;
typedef map<int,int>::iterator mii;
typedef set<int> st;
typedef deque<int> dq;

map<int, int> ma;
int main()
{
	char c[111][111] ;
	int n, i, j, m, k;

	cin >> n >> m;

	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			cin >> c[i][j];
		}
	}

	int cnt = 0;
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			int mx = -1;
			for(k=1;k<=n;k++){
				if(mx < (c[k][j] - '0')){
					mx = (c[k][j] - '0');
				}
			}
			if(mx == (c[i][j] - '0')){
				cnt ++;
				break;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}


#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::vector;
using std::string;
int main(int argc, const char *argv[]) {

    int n = 0; cin >> n;
    int m = 0; cin >> m;

    vector<vector<int>> a;

    for (int i = 0; i < n; ++i) {
        string s; cin >> s;
        vector<int> js;
        for (int j = 0; j < m; ++j) {
            js.push_back(s[j] - '1' + 1);
        }
        a.push_back(js);
    }

    int ppl[n]; for (int i = 0; i < n; ++i) { ppl[i] = 0; }

    for (int j = 0; j < m; ++j) {
        int max_val = 0; vector<int> max_pos;
        for (int i = 0; i < n; ++i) {
            if (a[i][j] > max_val) { max_val = a[i][j]; max_pos.clear(); max_pos.push_back(i); } else if (a[i][j] == max_val) { max_pos.push_back(i); }
        }
        for (int i : max_pos) {
            ppl[i]++;
        }
    }

    int count = 0;
    for (int i = 0; i < n; ++i) {
        if (ppl[i] > 0) {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}


//region Template
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
const double kEps    = 10e-8;
const int kMax       = 105;
const int kInf       = 1 << 30;
//endregion

int main(int argc, char **argv) {
    int n, m;
    char grades[kMax][kMax];
    scanf("%d %d\n", &n, &m);
    for (int i = 0; i < n; i++) {
        scanf("%s\n", grades[i]);
    }

    int M[m];
    for (int j = 0; j < m; j++) {
        int max_grade = 0;
        for (int i = 0; i < n; i++) {
            max_grade = max(max_grade, grades[i][j] - '0');
        }
        M[j] = max_grade;
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        bool is_successful = false;
        for (int j = 0; j < m && !is_successful; j++) {
            if (grades[i][j] - '0' == M[j]) {
                is_successful = true;
            }
        }
        if (is_successful) {
            ans++;
        }
    }

    cout << ans << endl;
    return EXIT_SUCCESS;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vch;
typedef vector<vector<int> > vvi;
typedef map<int,int> MPII;
typedef set<int> SET;
typedef multiset<int> MSET;

#define pc putchar
#define gc getchar
#define s(n) scanf("%d",&n)
#define sll(n) scanf("%lld",&n)
#define F(i,a,b) for(int i=a;i<=b;i++)
#define f(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define repn(i,n) F(i,1,n)
#define bit(x,i) ( x & (1 << i) )
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n)) //get the highest bit of x, maybe the fastest
#define fill(a,b)   memset(a,b,sizeof(a))
#define sz(a)      (int)(a.size())
#define MIN(a,b)     (a) = min((a),(b))
#define MAX(a,b)     (a) = max((a),(b))
#define ff first
#define ss second
#define ALL(v) (v).begin(),(v).end()
#define TR(i,x) for(typeof(x.begin()) i=x.begin();i!=x.end();i++)
#define pb push_back
#define mp make_pair
#define tri pair<int,pair<int,int> >
#define TRI(a,b,c) mp(a,mp(b,c))
#define xx ff
#define yy ss.ff
#define zz ss.ss
#define M 1000000007
#define INF (int)1e9 + 5;
#define EPS (double)(1e-9)
#define PI (double)(3.141592653589793)
#define MOD 1000000003
#define printall(a) rep(i,sz(a))cout<<a[i]<<endl;
#define vs vector<string>
const int N = 1000*100 + 5;
ll poww(ll a , ll n){if(n==0)return 1;if(n==1)return a%M;ll v=poww(a,n/2);v=(v*v)%M;if(n%2 == 1)return (v*a)%M;return v%M;}
inline void getInt(int& x){int c = gc();x=0;for(;(c<48 || c>57);c = gc());for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}}
inline void out_d(int n){if(n<0){n=-n;pc('-');}int i=10;char output_buffer[10];do{output_buffer[--i]=(n%10)+'0';n/=10;}while(n);do{pc(output_buffer[i]);}while(++i<10);pc(' ');}
priority_queue< pll > q;
string s[105];
int ma[105],n,m,ans;
int main() {ios::sync_with_stdio(false);
    cin>>n>>m;
    rep(i,n){
        cin>>s[i];
        rep(j,m){
            ma[j]=max(ma[j],((int)s[i][j]-48));
        }
    }
    rep(i,n){
        rep(j,m){
            if((int)s[i][j]-48>=ma[j]){ans++;break;}
        }
    }
    cout<<ans;
    return 0;
}


#include <iostream>
using namespace std;

int main() {
    char x[100][100];
    int m, n, count = 0;
    bool boolean = 0;
    cin >> m >> n;
    for (int i = 0; i < m; i++)
        for (int k = 0; k < n; k++)
            cin >> x[i][k];
    for (int i = 0; i < m; i++) {
        for (int k = 0; k < n; k++) {
            for (int f = 0; f < m; f++) {
                if (x[i][k] < x[f][k])
                    break;
                else if (f == m - 1)
                    boolean = 1;
            }
            if (boolean == 1) {
                count++;
                boolean = 0;
                break;
            }
        }
    }
    cout << count << endl;

    return 0;
}


#inclu de <iostream>
using namespace std;

int main() {
    char x[100][100];
    int m,n,count=0;
    bool boolean = 0;
    cin>>m>>n;
for (int i=0;i<m;i++)
    for(int k=0;k<n;k++)
        cin>>x[i][k];
for (int i=0;i<m;i++)
    {
    for(int k=0;k<n;k++)
        {
            for (int f=0;f<m;f++)
                {
                    if(x[i][k]<x[f][k])
                        break ;
                    else if(f==m-1)
                        boolean=1;
                }
            if(boolean==1)
                {
                    count++;
                    boolean=0;
                    break;
                }
        }
    }
cout<<count<<endl;

    return 0;
}


#include <iostream>

using namespace std;
int maxi[150];
int main()
{
    int n,m;
    cin>>n>>m;
    string vs[n];
    for(int i=0;i<n;i++)cin>>vs[i];
    for(int j=0;j<m;j++){
        for(int i=0;i<n;i++){
            maxi[j]=max(maxi[j],vs[i][j]-'0');
        }
    }
    int c=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(maxi[j]==vs[i][j]-'0'){c++;break;}
        }
    }
    cout<<c;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int n, m;
int c = 0;

int main() {
    cin >> n >> m;
    vector<string> s(n);
    vector<bool> used(n);
    for (int i = 0; i < n; i++)
        cin >> s[i];
    for (int i = 0; i < m; i++) {
        char b = 0;
        for (int j = 0; j < n; j++) {
            b = max(b, s[j][i]);
        }
        for (int j = 0; j < n; j++) {
            if (s[j][i] == b && !used[j]) {
                used[j] = true;
                c++;
            }
        }
    }
    cout << c << endl;
}


#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <bitset>
#include <algorithm>
#include <cstring>

using namespace std;

#define rep(i,a,b) for(int i = (a); i < int(b); ++i)
#define rrep(i, a, b) for(int i = (a) - 1; i >= b; --i)
#define trav(it, v) for(__typeof((v).begin()) it = (v).begin(); it != (v).end(); ++it)
#define all(v) (v).begin(), (v).end()

typedef double fl;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;

template<typename T>
istream& operator>>(istream& in, vector<T> &v) {
    rep(i,0,v.size()) in >> v[i];
    return in;
}

template<typename A, typename B>
istream& operator>>(istream& in, pair<A, B> &p) {
    in >> p.first >> p.second;
    return in;
}

template<typename T>
ostream& operator<<(ostream& out, vector<T> &v) {
    if(v.size()) out << v[0];
    rep(i,1,v.size()) out << ' ' << v[i];
    return out;
}

template<typename A, typename B>
ostream& operator<<(ostream& out, pair<A, B> &p){
    out << p.first << ' ' << p.second;
    return out;
}

int main(){
    int n, m;
    cin >> n >> m;
    vi mg(m);
    vector<string> g(n);
    cin >> g;
    rep(i,0,n)
        rep(j,0,m)
            if(g[i][j] > mg[j]) mg[j] = g[i][j];
    int ans = 0;
    rep(i,0,n)
        rep(j,0,m)
            if(mg[j] == g[i][j]){
                ans++;
                break;
            }
    cout << ans << endl;
}


#include <cstdio>
using namespace std;

int n,m,i,j,a[100][100],top[100],ans;

int main(){
    scanf("%d%d",&n,&m);
    for(i=0;i<n;i++) for(j=0;j<m;j++){
        scanf("%1d",&a[i][j]);
        if(a[i][j]>top[j]) top[j]=a[i][j];
    }
    for(i=0;i<n;i++){
        for(j=0;j<m;j++) if(a[i][j]==top[j]) break;
        if(j<m) ans++;
    }
    printf("%d\n",ans);
}


#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
bool mark[100];
int a[100][100];
void Tabdil(string b,int m,int n,int i)
{
		for(int j=0;j<m;j++)
			a[i][j]=b[j]-'0';
}
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		string b;
		cin>>b;
		Tabdil(b,m,n,i);
	}
	for(int j=0;j<m;j++)
	{
		int maxi=a[0][j];
		for(int i=0;i<n;i++)
		{
			maxi=max(maxi,a[i][j]);
		}
		for(int i=0;i<n;i++)
		{
			if(maxi==a[i][j])
				mark[i]=true;
		}
	}
	int ans=0;
	for(int i=0;i<n;i++)
		if(mark[i])
			ans++;
	cout<<ans;
	return 0;
}


#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;

int main(){
    int n,m,a[100][100],hi[100]={},ok[100]={};
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            scanf("%1d",&a[i][j]);
            hi[j]=max(hi[j],a[i][j]);
        }
    }
    for(int i=0;i<n;i++) for(int j=0;j<m;j++){
        if(a[i][j]==hi[j]) ok[i]=1;
    }
    printf("%d\n",count(ok,ok+n,1));
}


// #includes {{{
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <functional>
#include <cctype>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <utility>
#include <numeric>

using namespace std;
// }}}

// #define {{{
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int i=0; i<(n); ++i)
#define REP1(i,a,b) for(int i=(a); i<=(b); ++i)
#define MP make_pair
#define PB push_back

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
// }}}

// constance {{{
const double EPS = 1E-9;
const int INF = 1E9;
// }}}

int main(int argc, char const* argv[])
{
    ios_base::sync_with_stdio(false);
    int n, m;
    int c = 0;
    cin >> n >> m;
    vector<char> vsubjects(m);
    vector< vector<char> > vstudents(n);

    REP(i, n) {
        REP(j, m) {
            cin >> vsubjects[j];
        }
        vstudents[i] = vsubjects;
    }

    REP(i, n) {
        bool success = true;
        REP(j, m) {
            char grade = vstudents[i][j];
            REP(k, n) {
                if(i == k) continue;
                success = (grade >= vstudents[k][j]);
                if(!success) break;
            }
            if(success) break;
        }
        if(success) {
            ++c;
            continue;
        }
    }

    cout << c << endl;
    return 0;
}


// #includes {{{
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <functional>
#include <cctype>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <utility>
#include <numeric>

using namespace std;
// }}}

// #define {{{
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int i=0; i<(n); ++i)
#define REP1(i,a,b) for(int i=(a); i<=(b); ++i)
#define MP make_pair
#define PB push_back

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
// }}}

// constance {{{
const double EPS = 1E-9;
const int INF = 1E9;
// }}}

int main(int argc, char const* argv[])
{
    ios_base::sync_with_stdio(false);
    int n, m;
    int c = 0;
    cin >> n >> m;
    vector<int> vsubjects(n);
    vector<int> vstudents(n);
    REP(i, n) cin >> vsubjects[i];
    REP(i, n) {
        REP(j, m) {
            int div = (int)pow(10.0, j);
            int mark = ( vsubjects[i] / div) % 10;
            REP(k, n) {
                vstudents[k] = (vsubjects[k] / div) % 10;
            }
            auto maxit = max_element(ALL(vstudents));
            if ((*maxit) == mark) {
                ++c;
                break;
            }
        }
    }
    cout << c << endl;
    return 0;
}


// #includes {{{
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <functional>
#include <cctype>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <utility>
#include <numeric>

using namespace std;
// }}}

// #define {{{
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int i=0; i<(n); ++i)
#define REP1(i,a,b) for(int i=(a); i<=(b); ++i)
#define MP make_pair
#define PB push_back

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
// }}}

// constance {{{
const double EPS = 1E-9;
const int INF = 1E9;
// }}}

int main(int argc, char const* argv[])
{
    ios_base::sync_with_stdio(false);
    int n, m;
    int c = 0;
    cin >> n >> m;
    vector<int> vsubjects(n);
    vector<int> vstudents(n);
    vector<int> vsuccess(n);
    REP(i, n) cin >> vsubjects[i];
    REP(j, m) {
        int mod = (int)pow(10.0, j);
        REP(i, n) {
            vstudents[i] = (vsubjects[i] / mod) % 10;
        }
        for (int k = 9; k > 0 ; --k) {
            bool ismax = false;
            REP(i, n) {
                if (vstudents[i] == k) {
                    ++vsuccess[i];
                    ismax = true;
                }
            }
            if(ismax) break;
        }
    }
    c = count_if(ALL(vsuccess), [](int num){return num > 0;});
    cout << c << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main ()
{
	ios_base::sync_with_stdio(0); cin.tie(0);

	int n, m;
	vector<string> v;
	vector<int> best;

	while(cin >> n >> m)
	{
		v.resize(n);
		best.resize(m);

		for (int i = 0; i < n; ++i) cin >> v[i];

		for (int j = 0; j < m; ++j)
		{
			int max = v[0][j] - '0';
			for (int i = 1; i < n; ++i)
			{
				if (v[i][j] - '0' > max) max = v[i][j] - '0';
			}
			best[j] = max;
		}

		int cnt = 0;
		for (int i = 0; i < n; ++i)
		{
			for (int j = 0; j < m; ++j)
			{
				if (v[i][j] - '0' == best[j])
				{
					cnt++;
					break;
				}
			}
		}

		cout << cnt << endl;
	}

	return 0;
}


#include <iostream>
#include <cstdlib>
#include <string>
#include <cctype>
#include <vector>
#include <set>
#include <algorithm>  /* max, transform, sort, upper_bound */
#include <functional>  /* greater */
#include <iterator>    /* std::ostream_iterator */
// #include <regex>  // XXX
#include <limits>
#include <iomanip>  // setprecision
#include <map>

using namespace std;

string capslock()
{
    string str;
    cin >> str;

    string::iterator iter = str.begin();

    /* iterate until end or the first lower case letter */
    while (iter != str.end() && isupper(*iter))
        ++iter;

    bool swap_case = false;

    if (iter == str.end())  /* all the letters are upper case */
        swap_case = true;
    else if (iter == str.begin())  /* the 1st letter is lower case */
    {
        ++iter;
        while (iter != str.end() && isupper(*iter))
            ++iter;

        swap_case = (iter == str.end());  /* the remaining letters are upper case */
    }

    if (swap_case)
        for (iter = str.begin(); iter != str.end(); ++iter)
            *iter = isupper(*iter) ? tolower(*iter) : toupper(*iter);

    return str;
}

int gcd(const int a, const int b)  /* greatest common divisor */
{
    int x = max(abs(a), abs(b));
    int y = min(abs(a), abs(b));
    int r = x % y;

    while (r != 0)
    {
        x = y;
        y = r;
        r = x % y;
    }

    return y ? y : x;
}

int epic_game() /* http://codeforces.com/problemset/problem/119/A */
{
    int a, b, n;
    cin >> a >> b >> n;

    while (true)
    {
        if ( n != 0 )
            n -= gcd(n, a);
        else
            return 1;

        if ( n != 0 )
            n -= gcd( n, b );
        else
            return 0;
    }
}

int team()  /* http://codeforces.com/problemset/problem/231/A */
{
    int n, res = 0;
    cin >> n;

    for ( int j = 0; j < n; ++j )
    {
        int s = 0, a;
        for ( int  k = 0; k < 3; ++k )
        {
            cin >> a;
            s += a;
        }

        res += (s > 1);
    }

    return res;
}

int petya_strings()  /* http://codeforces.com/problemset/problem/112/A */
{
    vector < string > str;

    for (int j = 0; j < 2; ++j)
    {
        string s;
        cin >> s;
        str.push_back (s);
    }

    // for ( vector < string >::iterator i = str.begin(); i != str.end(); ++i)
    //     transform ( i->begin(); i->end(); i->begin(); tolower )
    // XXX
    for_each ( str.begin(), str.end(),
            [](string & a) { transform ( a.begin(), a.end(), a.begin(), ::tolower );} );  // XXX

    return str[0] < str[1] ? -1 :
        str[0] > str[1] ? 1 : 0;
}

int stones_on_the_table()  /* http://codeforces.com/problemset/problem/266/A */
{
    int n, k = 0;
    string colstr;

    cin >> n >> colstr;

    for (string::const_iterator iter = colstr.begin() + 1; iter != colstr.end(); ++iter)
        k += *iter == *(iter-1);

    return k;
}

int bitpp()  /* http://codeforces.com/problemset/problem/282/A */
{
    int n, res = 0;
    string str;

    cin >> n;

    for ( int j=0; j < n; ++j )
    {
        cin >> str;
        res += (str[0] == '+' || str[2] == '+') ? 1 : -1;
    }

    return res;
}

int insomnia_cure ()  /* http://codeforces.com/problemset/problem/148/A */
{
    vector <int> k;
    int d, a, res = 0;

    for (int j = 0; j < 4; ++j) {
        cin >> a;
        k.push_back(a);
    }

    cin >> d;

    for ( int j = 1; j <= d; ++j )
        for ( vector<int>::const_iterator iter = k.begin(); iter != k.end(); ++iter )
            if (! (j % *iter) ) {
                ++res;
                break;
            }

    return res;
}

string hq9p()  /* http://codeforces.com/problemset/problem/133/A */
{
    string str;
    cin >> str;

    return str.find_first_of ( "HQ9" ) != string::npos ?
        "YES" : "NO";
}

string football()  /* http://codeforces.com/problemset/problem/96/A */
{
    string str;
    cin >> str;

    return str.find ( "1111111" ) != string::npos
        || str.find ( "0000000" ) != string::npos ?
        "YES" : "NO";
}

int twin ()  /* http://codeforces.com/problemset/problem/160/A */
{
    int n, sum_elm = 0;
    cin >> n;

    vector <int> a(n);

    // for (vector <int>::iterator iter = a.begin() ; *iter != a.end(); ++iter)
    //     cin >> *iter;

    // XXX
    for_each ( a.begin(), a.end(), [&](int &x) {
            cin >> x;
            sum_elm += x;
            } );

    // XXX greater is a class, greater < int > () returns an object
    sort ( a.begin(), a.end(), greater <int> () );
    partial_sum ( a.begin(), a.end(), a.begin() );

    return upper_bound ( a.begin(), a.end(), sum_elm / 2)
        - a.begin() + 1;
}

int horseshoe ()  /* http://codeforces.com/problemset/problem/228/A */
{
    vector <int> s(4);

    for (vector <int>::iterator iter = s.begin(); iter != s.end(); ++iter)
        cin >> *iter;

    set <int> x ( s.begin(), s.end() );
    // for_each ( s.begin(), s.end(), [&x](const int &y) {
    //         x.insert(y);
    //         } );

    return 4 - x.size();

    // sort ( s.begin(), s.end() );
    // return s.end() - unique ( s.begin(), s.end() );
}

int arrival_of_general ()  /* http://codeforces.com/problemset/problem/144/A */
{
    int n;
    cin >> n;

    vector <int> a ( n );
    for (vector <int>::iterator iter = a.begin(); iter != a.end(); ++iter)
        cin >> *iter;

    // XXX
    pair<vector <int>::const_iterator, vector <int>::const_iterator>
        min_max = minmax_element (a.begin (), a.end ());

    const int jmax = find( a.begin(), a.end(), *min_max.second ) - a.begin();
    const int jmin = find( a.rbegin(), a.rend(), *min_max.first ) - a.rbegin(); // XXX

    return jmax + jmin - (jmin + jmax > n - 2);
}

string nearly_lucky_num ()  /* http://codeforces.com/problemset/problem/110/A */
{
    string str;
    std::cin >> str;

    int ln = count( str.begin(), str.end(), '4' )
        + count( str.begin(), str.end(), '7' );

    // string lns( ::itoa(ln) ); // = to_string (ln);

    // return static_cast <int> ( lns.length() ) == count ( lns.begin(), lns.end(), '4' )
    //     + count( lns.begin(), lns.end(), '7' ) ? "YES" : "NO";

    do
    {
        const int res = ln % 10;

        if ( res != 7 && res != 4 )
            return "NO";

        ln /= 10;

    } while ( ln );

    return "YES";
}

void presents ()  /* http://codeforces.com/problemset/problem/136/A */
{
    int n;
    cin >> n;

    vector<int> a( n );
    for (vector <int>::iterator iter = a.begin(); iter != a.end(); ++iter)
        cin >> *iter;

    vector<int> x( n );

    vector<int>::const_iterator iter = a.begin();

    for ( int j = 1; iter != a.end(); ++j, ++iter )
        x[ *iter - 1] = j;

    // XXX
    // cout << x.value_type;
    ostream_iterator <int> out_iter (cout, " ");
    copy ( x.begin(), x.end(), out_iter );
}

string queue_at_the_school ()  /* http://codeforces.com/problemset/problem/266/B */
{
    int n, t;
    cin >> n >> t;

    string str;
    cin >> str;

    for ( int j = 0; j < t; ++j )
        for ( string::iterator iter = str.begin (); iter < str.end (); ++iter)
            if ( *iter == 'B' && *(iter + 1) == 'G' ) {
                *iter = 'G';
                *(iter + 1) = 'B';
                ++iter;
            }

    return str;
}

string boy_or_girl ()  /* http://codeforces.com/problemset/problem/236/A */
{
    string str;
    cin >> str;

    const set <char> chset(str.begin(), str.end());

    return chset.size() % 2 ? "IGNORE HIM!" : "CHAT WITH HER!";

}

int games () /* http://codeforces.com/problemset/problem/268/A */
{
    int n;
    cin >> n;

    // XXX
    vector < pair<int, int> > col( n );

    for ( vector < pair<int, int> >::iterator iter = col.begin (); iter != col.end(); ++iter )
        cin >> iter->first >> iter->second;

    int res = 0;

    // XXX XXX
    for_each ( col.begin (), col.end (), [&col, &res] ( const pair<int, int> & x )
            {
            for_each ( col.begin (), col.end (), [&x, &res] ( const pair <int, int> & y )
                {
                res += x.first == y.second;
                } );
            } );

    return res;
}

int beautiful_year ()  /* http://codeforces.com/problemset/problem/271/A */
{
    int n;
    cin >> n;

    set <int> s;

    for ( ; s.size() != 4; ++n )
    {
        s.clear();
        for ( int j = n + 1; j; j /= 10 )
            s.insert ( j % 10 );
    }

    return n;
}

string word_capitalization ()  /* http://codeforces.com/problemset/problem/281/A */
{
    string str;
    cin >> str;

    str[0] = toupper(str[0]);
    return str;
}

int beautiful_matrix ()  /* http://codeforces.com/problemset/problem/263/A */
{
    bool bit;

    for ( int i = 0; ; ++i )
        for ( int j = 0; j < 5; ++j )
        {
            cin >> bit;
            if (bit)
                return abs(i-2) + abs(j-2);
        }
}

string ultra_fast_mathematician ()  /* http://codeforces.com/problemset/problem/61/A */
{
    string a, b, x;
    cin >> a >> b;

    for ( string::const_iterator i = a.begin(), j = b.begin();
            i != a.end() && j != b.end(); ++i, ++j )
        x.push_back( *i == *j ? '0' : '1' );

    return x;
}

void b118 ( ) /* http://codeforces.com/problemset/problem/118/B  */
{
    int n;
    cin >> n;

    for ( int i = 0; i <= 2*n; ++i, cout << '\n' )
    {
        const int k = i < n ? i : 2*n - i;

        for ( int j = 0; j < n - k; ++ j )
            cout << "  ";

        for ( int j = 0; j <= k; ++j, cout << ( j <= k ? " " : "" ) )
            cout << j;

        for ( int j = k-1; j >= 0; --j)
            cout << ' ' << j;
    }
}

int a155 ( )  /* http://codeforces.com/problemset/problem/155/A */
{
    int n;
    cin >> n;

    vector < int > a(n);

    // XXX only works with Ctrl+D at the end
    // copy (istream_iterator <int> ( cin ), istream_iterator <int> (), a.begin () );

    // XXX c++11
    copy_n ( istream_iterator <int> ( cin ), n, a.begin() );

    int k = 0, rmin = a[0], rmax = a[0];

    for_each ( a.begin(), a.end (), [&rmin, &rmax, &k] ( const int x )
            {
                if ( x > rmax )
                {
                    rmax = x;
                    ++k;
                }
                else if ( x < rmin )
                {
                    rmin = x;
                    ++k;
                }
            } );

    return k;
}

int a149 ( )  /* http://codeforces.com/problemset/problem/149/A  */
{
    int k;
    cin >> k;

    if ( ! k ) return 0;

    vector <int> a ( 12 );
    copy_n ( istream_iterator <int> ( cin ), 12, a.begin() );

    sort ( a.begin(), a.end(), greater<int> ( ) );
    partial_sum ( a.begin(), a.end(), a.begin () );

    vector <int>::const_iterator iter = lower_bound ( a.begin(), a.end (), k );

    return iter != a.end() ? iter - a.begin() + 1: -1;
}

string a208 ( )  /* http://codeforces.com/problemset/problem/208/A */
{
    string str;
    cin >> str;

    // XXX consider rfind for a possibly faster substitution
    for ( size_t pos = str.find ( "WUB" ); pos != string::npos; pos = str.find ( "WUB" ) )
        str.replace ( pos, 3, pos > 0 && str[ pos - 1 ] != ' ' ? " " : "" );

    return str;
}

int d158 ( )  /* http://codeforces.com/problemset/problem/158/D */
{
    int n;
    cin >> n;

    vector <int> t ( n );
    copy_n ( istream_iterator <int> ( cin ), n, t.begin () );

    int maxsum ( numeric_limits< int >::min() ); // XXX

    // XXX consider an iterator class which iterates divisors of n
    for ( int k = 1 ; k <= n / 3 ; ++k )  /* group size */
        if ( ! (n % k) )
            for ( vector <int>::const_iterator j = t.begin() ; j != t.begin() + k ; ++j )
            {
                int sum = 0L;

                for ( vector <int>::const_iterator iter = j; iter < t.end();
                        sum += *iter, iter += k ) ;

                if ( sum > maxsum ) maxsum = sum;
            }

    return maxsum;
}

int a124 ( )  /* http://codeforces.com/problemset/problem/124/A */
{
    int n, a, b;
    cin >> n >> a >> b;

    /*
     * no less than a people in front
     * no more than b people behind
     */

    return n - max ( a, n - b - 1);
}

int a278 ( )  /* http://codeforces.com/problemset/problem/278/A */
{
    int n, s, t;
    cin >> n;

    vector <int> d(n);
    copy_n ( istream_iterator < int > ( cin ), n, d.begin () );

    cin >> s >> t;

    const int total = accumulate ( d.begin(), d.end(), 0 );

    vector < int >::const_iterator first = d.begin() + min(s, t) - 1;
    vector < int >::const_iterator last  = d.begin() + max(s, t) - 1;

    const int partial = accumulate ( first, last, 0 );
    return min ( partial, total - partial );
}

void a270 ( )  /* http://codeforces.com/problemset/problem/270/A */
{
    int n;
    cin >> n;

    vector < int > alpha(n);
    copy_n ( istream_iterator < int >( cin ), n, alpha.begin () );

    for_each ( alpha.begin (), alpha.end (), [](const int a ) {
            cout << ( 360 % (180 - a) ? "NO" : "YES" ) << '\n' ; } );
}

const char * a230 ( )  /* http://codeforces.com/problemset/problem/230/A */
{
    int s, n;
    cin >> s >> n;

    vector < pair <int, int> > drg ( n );
    for ( vector < pair <int, int> >::iterator iter = drg.begin(); iter != drg.end(); ++iter )
        cin >> iter->first >> iter->second;

    /*
     * greedy alg: of all the dragons with less power,
     * take on the one with highest boost
     * sort based on xi and set-up list which will be traveresed repeatedly
     */

    // XXX
    struct Comp
    {
        bool operator ()( const pair <int, int> & a, const pair <int, int> & b )
        {
            return a.first < b.first
                || ( a.first == b.first && a.second > b.second );
        };
    } ; // Comp;

    // sort ( drg.begin (), drg.end (), Comp );

    // for ( vector < pair <int, int>::iterator iter = drg.begin();
    //         iter != drg.end() && s > iter->first ; s += iter->second , ++iter )
    //     ;

    return "YES";
}

double b200 ( ) /* http://codeforces.com/problemset/problem/200/B */
{
    int n; cin >> n;

    vector <int> x ( n );

    copy_n ( istream_iterator <int> ( cin ), n, x.begin() );

    return accumulate ( x.begin(), x.end(), 0.0 ) / n;
}

int a48 ( ) /* http://codeforces.com/problemset/problem/84/A */
{
    int n; cin >> n;

    return n * 3 / 2;
}

void b263 ( )  /* http://codeforces.com/problemset/problem/263/B */
{
    int n, k;
    cin >> n >> k;

    if ( k > n )
    {
        cout << -1;
        return;
    }

    vector <int> a ( n );
    copy_n ( istream_iterator < int > ( cin ), n, a.begin() );

    partial_sort ( a.begin(), a.begin() + n - k + 1, a.end() );

    cout << a[n - k] << ' ' << 0;
}

int a265 ( )  /* http://codeforces.com/problemset/problem/265/A */
{
    string s, t;
    cin >> s >> t;

    string::const_iterator pos = s.begin();

    for ( string::const_iterator ins = t.begin();
          ins != t.end();
          pos += *pos == *ins++ )
        ;

    return pos - s.begin() + 1;
}

int a168 ( )  /* http://codeforces.com/problemset/problem/168/A */
{
    int n, x, y;
    cin >> n >> x >> y;

    return static_cast < int > ( ceil ( max ( n * y / 100.0  - x, .0 )));
}

long long a318 ( ) /* http://codeforces.com/problemset/problem/318/A */
{
    long long n, k;
    cin >> n >> k;

    return ( k > ( n + 1 ) / 2 )
        ? 2 * ( k - ( n + 1 ) / 2 )
        : 2 * k - 1;
}

template < class InputIterator >  // XXX XXX XXX
inline map < typename iterator_traits< InputIterator >::value_type,
             typename iterator_traits< InputIterator >::difference_type >
count_each ( InputIterator first, InputIterator last )
{
    typedef typename iterator_traits<InputIterator>::value_type      key_type; // XXX XXX XXX XXX
    typedef typename iterator_traits<InputIterator>::difference_type mapped_type;
    // typedef typename pair < const key_type, mapped_type > value_type;

    map < key_type, mapped_type > count;
    for ( ; first != last; ++count[ *first++ ] )  // XXX
        ;
    return count;
}

string a219 ( ) /* http://codeforces.com/problemset/problem/219/A */
{
    int k; cin >> k;
    string str; cin >> str;

    // XXX
    typedef typename iterator_traits< string::iterator >::difference_type  difference_type;

    map <string::value_type, difference_type> count (
            count_each< string::iterator > ( str.begin(), str.end() ));

    string wrd;
    for ( map <char, difference_type>::const_iterator iter = count.begin();
            iter != count.end(); ++iter )

        if ( iter->second % k ) return "-1";
        else wrd += string ( iter->second / k, iter->first );

    string res;
    for ( int j = 0; j < k; ++j, res += wrd )
        ;

    return res;
}

string a59 ( )  /* http://codeforces.com/problemset/problem/59/A */
{
    string str;
    cin >> str;

    const unsigned k = count_if ( str.begin(), str.end(), ::isupper ); // XXX

    int (* oper ) ( int ) ( k > str.length() / 2 ? ::toupper : ::tolower );  // XXX
    transform ( str.begin(), str.end(), str.begin(), oper );  // XXX

    return str;
}

void a221 ( )  /* http://codeforces.com/problemset/problem/221/A */
{
    int n; cin >> n;

    cout << n;
    for ( int j = 1; j < n; cout << ' ' << j++ )
        ;
}

int a129 ( ) /* http://codeforces.com/problemset/problem/129/A */
{
    int n; cin >> n;

    vector <int> a ( n );
    copy_n ( istream_iterator <int> ( cin ), n, a.begin() );

    const int sum = accumulate (a.begin(), a.end(), 0 );

    // template < class T > // XXX
    // struct is_odd : unary_function < int, bool >
    // {
    //     bool operator () ( const int & x ) const { return x % 2; }
    // };

    // const int nodd = count_if ( a.begin(), a.end(), is_odd() ); // XXX
    const int nodd = count_if ( a.begin(), a.end(), [](const int & x) { return x % 2; });

    return sum % 2 ? nodd : n - nodd;
}

int a224 ( )  /* http://codeforces.com/problemset/problem/224/A */
{
    int x, y, z;
    cin >> x >> y >> z;

    int a = sqrt ( x * y / z ),
        b = sqrt ( x * z / y ),
        c = sqrt ( y * z / x );

    return 4 * ( a + b + c );
}

int a262 ( ) /* http://codeforces.com/problemset/problem/262/A */
{
    int n, k;
    cin >> n >> k;

    vector < string > str ( n );
    copy_n ( istream_iterator < string > ( cin ), n, str.begin () );

    // XXX
    return count_if ( str.begin(), str.end(), [ &k ] ( const string & a )
            { return count_if ( a.begin(), a.end(), [] ( const char & ch )
                { return ch == '4' || ch == '7'; } ) <= k; } );
}

const char * a146 ( )  /* http://codeforces.com/problemset/problem/146/A */
{
    int n; cin >> n;

    string str;
    cin >> str;

    if ( find_if ( str.begin(), str.end(), [] ( const char & ch )
                { return ch != '4' && ch != '7'; } ) != str.end() )
        return "NO";

    const int s0 = accumulate ( str.begin(), str.begin() + n/2, 0,  // XXX
            [] ( int a, const char & ch ) { return a + ( ch - '0' ); } );

    const int s1 = accumulate ( str.begin() + n/2, str.end(), 0,
            [] ( int a, const char & ch ) { return a + ( ch - '0' ); } );

    return s0 == s1 ? "YES" : "NO";
}

void a114 ( ) /* http://codeforces.com/problemset/problem/114/A */
{
    int k, l;
    cin >> k >> l;

    const int p = ::round ( ::log ( l ) / ::log ( k ));

    const double err = ::pow(k, p) - l;  // XXX
    const double abserr = err > 0 ? err : -err;

    if ( abserr < 1e-8 )
        cout << "YES\n" << p - 1;
    else
        cout << "NO";
}

void a330 ( )  /* http://codeforces.com/problemset/problem/300/A */
{
    int n; cin >> n;

    vector <int> a ( n );
    copy_n ( istream_iterator < int > ( cin ), n, a.begin( ));

    // const int n1 = count_if ( a.begin(), a.end(), bind2nd ( less < int > (), 0 ));

    int n1 = 0, n2 = 0, n3 = 0;
    for_each ( a.begin(), a.end(), [ &n1, &n2, &n3 ] ( const int & x ) {
            if      ( x > 0 ) ++n2;
            else if ( x < 0 ) ++n1;
            else              ++n3; } );

    if ( ! ( n1 % 2 ))
        n2 = n - ++n3 - 1;
    else
        n2 = n - n3 - 1;

    vector< int >::iterator iter1 = find_if ( a.begin(), a.end(),
            bind2nd ( less <int> ( ), 0 ) );

    const vector< int >::const_iterator iter2 = ! ( n1 % 2 )
        ? find_if ( iter1 + 1, a.end(), bind2nd ( less <int> ( ), 0 ))
        : iter1;

    cout << 1 << ' ' << *iter1 << '\n' << n2;

    for ( vector <int>::const_iterator j = a.begin(); j != a.end(); ++ j )
        if ( *j && j != iter1 && j != iter2 )
            cout << ' ' << *j;

    ostream_iterator <int> out_iter (cout, " ");

    // cout << n1 << " ";
    // copy_if ( a.begin(), a.end(), out_iter, bind2nd ( less < int > (), 0 ));

    // cout << '\n' << n2 << " ";
    // copy_if ( a.begin(), a.end(), out_iter, bind2nd ( greater < int > (), 0 ));

    cout << '\n' << n3 << " ";
    copy_if ( a.begin(), a.end(), out_iter, bind2nd ( equal_to < int > (), 0 ));

    if ( ! ( n1 % 2 ))
        cout << ' ' << * iter2;

}

int a215 ( )  /* http://codeforces.com/problemset/problem/215/A */
{
    int n, m;
    cin >> n;
    vector < int > a ( n );
    copy_n ( istream_iterator < int > ( cin ), n, a.begin() );

    cin >> m;
    vector < int > b ( m );
    copy_n ( istream_iterator < int > ( cin ), m, b.begin() );

    int ratio = 1, k = 0;

    for_each ( a.begin(), a.end(), [&k, &ratio, &b]( const int & x ) {
            for_each ( b.begin(), b.end(), [&k, &x, &ratio] (const int & y) {
                if ( ! (y % x) )
                {
                    const int frac = y / x;
                    if ( frac > ratio )
                    {
                        ratio = frac;
                        k = 0;
                    }

                    k +=  frac == ratio;
                } } ); } );
    return k;
}

int a152 ( )  /* http://codeforces.com/problemset/problem/152/A */
{
    int n, m;
    cin >> n >> m;

    vector < vector < char > > score (m, vector < char > ( n ));

    for ( int j = 0; j < n; ++j )
        for ( vector < vector < char > >::iterator iter = score.begin(); iter != score.end(); ++iter )
            cin >> (*iter)[ j ];

    set <int > top;
    for ( vector < vector < char > >::iterator iter = score.begin(); iter != score.end(); ++iter )
    {
        vector<char>::iterator j = max_element ( iter->begin(), iter->end() );
        const char max_score = *j;

        do
        {
            top.insert ( j - iter->begin() );
            j = find ( j + 1, iter->end(), max_score );
        }
        while ( j != iter->end() );
    }

    return top.size();
}

int main()
{
    cout << a152 ();

    return EXIT_SUCCESS;
}


#include <iostream>
using namespace std;
typedef long long ll;
ll t[100][100];
int main() {
    ll n,m;
    cin>>n>>m;
    for(ll i=0; i<n; ++i) {
        for(ll j=0; j<m ;++j) {
            char q;
            cin>>q;
            q-='0';
            t[i][j]=q;
        }
    }
    ll ma=0;
    for(ll i=0; i<n; ++i) {
        ll q=0;
        for(ll j=0; j<m; ++j) {
            for(ll k=0; k<n; ++k) {
                if(t[k][j]>t[i][j]) goto ohi;
            }
            q=1;
            ohi:;
        }
        ma+=q;
    }
    cout<<ma<<'\n';
}


#include <cstdio>
#include <iostream>
using namespace std;

int main(){
    int numStudents, numCourses; scanf("%d %d\n", &numStudents, &numCourses);
    int maxGrade = 0; char temp;
    bool *successful = new bool[numStudents];
    int *grades = new int[numStudents * numCourses];

    for(int n = 0; n < numStudents; n++){
        for(int m = 0; m < numCourses; m++){scanf("%c", &temp); grades[n * numCourses+ m] = temp - '0';}
        scanf("\n");
    }

    for(int n = 0; n < numStudents; n++){successful[n] = 0;}

    for(int m = 0; m < numCourses; m++){
        maxGrade = 0;
        for(int n = 0; n < numStudents; n++){maxGrade = max(maxGrade, grades[n * numCourses + m]);}
        for(int n = 0; n < numStudents; n++){if(grades[n * numCourses + m] == maxGrade){successful[n] = 1;}}
    }

    int total = 0;
    for(int student = 0; student < numStudents; student++){total += successful[student];}
    printf("%d\n", total);
    return 0;
}


#include <cstdio>
#include <iostream>
using namespace std;

int main(){
    int numStudents, numCourses; scanf("%d %d\n", &numStudents, &numCourses);
    int maxGrade = 0; char temp;
    bool *successful = new bool[numStudents];
    int *grades = new int[numStudents];

    for(int n = 0; n < numStudents; n++){
        for(int m = 0; m < numCourses; m++){scanf("%c", &temp); grades[n * numCourses+ m] = temp - '0';}
        scanf("\n");
    }

    for(int n = 0; n < numStudents; n++){successful[n] = 0;}

    for(int m = 0; m < numCourses; m++){
        maxGrade = 0;
        for(int n = 0; n < numStudents; n++){maxGrade = max(maxGrade, grades[n * numCourses + m]);}
        for(int n = 0; n < numStudents; n++){if(grades[n * numCourses + m] == maxGrade){successful[n] = 1;}}
    }

    int total = 0;
    for(int student = 0; student < numStudents; student++){total += successful[student];}
    printf("%d\n", total);
    return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main(){
    short  n, m, arrmax[101], sum = 0;
    string arr[101];
    bool is[101][101] = { 0 };
    cin >> n >> m;
    for (short i = 0; i < n; i++){
            cin >> arr[i];

    }

    for (short i = 0; i < m; i++){
        int max;
        for (short j = 0; j < n; j++){
            if (j == 0){
                max = arr[j][i]-'0';
            }
            else {
                if((arr[j][i]-'0')>max)
                max = arr[j][i]-'0';
            }
            if (j ==n - 1)
                arrmax[i] = max;
        }
    }

    for (short i = 0; i < m; i++){
        for (short j = 0; j <n; j++){
            if ((arr[j][i]-'0') == arrmax[i])
                is[j][i] = 1;
        }
    }

    for (short i = 0; i < n; i++){
        for (short j = 0; j < m; j++){
            if (is[i][j] == 1){
                sum++;
                break;
            }
        }
    }

    cout << sum;
    return 0;
}


#include <stdio.h>
#include <algorithm>
using namespace std;
#define N 100003
long a[N], b[N];

bool mySorting(int i, int j)
{
	return a[i] < a[j];
}

int main()
{
	long n;
	scanf("%ld", &n);
	for (int i = 0; i < n; ++i)
		scanf("%ld%ld", &a[i], &b[i]);

	//Sap xep theo mang
	int cs[N];
	for (int i = 0; i < n; ++i)
		cs[i] = i;

	sort(cs, cs + n, mySorting);

	int i = 0;
	bool ans = false;
	while (i < n - 1)
	{
		if (b[cs[i]] > b[cs[i+1]])
		{
			ans = true;
			break;
		}
		i++;
	}
	if (ans)
		printf("Happy Alex");
	else
		printf("Poor Alex");

	return 0;
}


#include <stdio.h>
#include <algorithm>
using namespace std;
#define N 100003
pair<long, long> laptop[N];

bool mySorting(pair<long, long> a, pair<long, long> b)
{
	return a.first < b.first;
}

int main()
{
	long n;
	scanf("%ld", &n);
	for (int i = 0; i < n; ++i)
		scanf("%ld%ld", &laptop[i], &laptop[i]);

	//Sort laptops by price
	sort(laptop, laptop + n, mySorting);

	int i = 0;
	bool ans = false;
	while (i < n - 1)
	{
		if (laptop[i].second > laptop[i + 1].second)
		{
			ans = true;
			break;
		}
		i++;
	}
	if (ans)
		printf("Happy Alex");
	else
		printf("Poor Alex");

	return 0;
}


#include <stdio.h>
#include <algorithm>
using namespace std;
#define N 100003

int main()
{
	long a[N], b[N];
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%d%d", &a[i], &b[i]);

	//Sap xep theo mang
	for (int i = 0; i < n - 1; ++i)
		for (int j = i + 1; j < n; ++j)
			if (a[i] > a[j])
			{
				swap(a[i], a[j]);
				swap(b[i], b[j]);
			}
	int i = 0;
	bool ans = true;
	while (i < n - 1)
	{
		if (b[i] <= b[i+1])
			ans = false;
			break;
		i++;
	}
	if (ans)
		printf("Happy Alex");
	else
		printf("Poor Alex");

	return 0;
}


#include <stdio.h>
#include <algorithm>
using namespace std;
#define N 100003

int main()
{
	long a[N], b[N];
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%d%d", a[i], b[i]);

	//Sap xep theo mang
	for (int i = 0; i < n - 1; ++i)
		for (int j = i + 1; j < n; ++j)
			if (a[i] > a[j])
			{
				swap(a[i], a[j]);
				swap(b[i], b[j]);
			}
	int i = 0;
	bool ans = true;
	while (i < n - 1)
	{
		if (b[i] <= b[i+1])
			ans = false;
			break;
		i++;
	}
	if (ans)
		printf("Happy Alex");
	else
		printf("Poor Alex");

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS 0

#include <stdio.h>
#include <algorithm>
using namespace std;
#define N 100003
pair<long, long> laptop[N];

bool mySorting(pair<long, long> a, pair<long, long> b)
{
	return a.first < b.first;
}

int main()
{
	long n;
	scanf("%ld", &n);
	for (int i = 0; i < n; ++i)
		scanf("%ld%ld", &laptop[i].first, &laptop[i].second);

	//Sort laptops by price
	sort(laptop, laptop + n, mySorting);

	int i = 0;
	bool ans = false;
	while (i < n - 1)
	{
		if (laptop[i].second > laptop[i + 1].second)
		{
			ans = true;
			break;
		}
		i++;
	}
	if (ans)
		printf("Happy Alex");
	else
		printf("Poor Alex");

	return 0;
}


#include <stdio.h>
#include <algorithm>
using namespace std;
#define N 100003
long a[N], b[N];

bool mySorting(int i, int j)
{
	return a[i] < a[j];
}

int main()
{
	long n;
	scanf("%ld", &n);
	for (int i = 0; i < n; ++i)
		scanf("%ld%ld", &a[i], &b[i]);

	//Sap xep theo mang
	int cs[N];
	for (int i = 0; i < n; ++i)
		cs[i] = i;

	sort(cs, cs + n, mySorting);

	int i = 0;
	bool ans = false;
	while (i < n - 1)
	{
		if (b[cs[i]] > b[cs[i+1]])
			ans = true;
			break;
		i++;
	}
	if (ans)
		printf("Happy Alex");
	else
		printf("Poor Alex");

	return 0;
}


#include <stdio.h>
#include <algorithm>
using namespace std;
#define N 100003
long a[N], b[N];

bool mySorting(int i, int j)
{
	return a[i] < a[j];
}

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%d%d", &a[i], &b[i]);

	//Sap xep theo mang
	int cs[N];
	for (int i = 0; i < n; ++i)
		cs[i] = i;

	sort(cs, cs + n, mySorting);

	int i = 0;
	bool ans = false;
	while (i < n - 1)
	{
		if (b[cs[i]] > b[cs[i+1]])
			ans = true;
			break;
		i++;
	}
	if (ans)
		printf("Happy Alex");
	else
		printf("Poor Alex");

	return 0;
}


#include <stdio.h>
#include <algorithm>
using namespace std;
#define N 100003
pair<long, long> laptop[N];

bool mySorting(pair<long, long> a, pair<long, long> b)
{
	return a.first < b.first;
}

int main()
{
	long n;
	scanf("%ld", &n);
	for (int i = 0; i < n; ++i)
		scanf("%ld%ld", &laptop[i], &laptop[i]);

	//Sort laptops by price
	sort(laptop, laptop + n, mySorting);

	int i = 0;
	bool ans = false;
	while (i < n - 1)
	{
		if (laptop[i].second > laptop[j].second)
		{
			ans = true;
			break;
		}
		i++;
	}
	if (ans)
		printf("Happy Alex");
	else
		printf("Poor Alex");

	return 0;
}


#include <stdio.h>
#include <algorithm>
using namespace std;
#define N 100003
long a[N], b[N];

bool mySorting(int i, int j)
{
	return a[i] < a[j];
}

int main()
{
	long n;
	scanf("%ld", &n);
	for (int i = 0; i < n; ++i)
		scanf("%ld%ld", &a[i], &b[i]);

	bool ans = false;
	for (int i = 0; i < n - 1; i++)
	for (int j = i + 1; j < n; ++j)
	if (a[i] > a[j] && b[i] < b[j] || a[i] < a[j] && b[i] > b[j])
	{
		ans = true;
		break;
	}
	if (ans)
		printf("Happy Alex");
	else
		printf("Poor Alex");

	return 0;
}


#include<iostream>
using namespace std;
int main()
{
    unsigned int n, p[100000], a[100000];
    bool x = false;
    cin >> n;
    for (unsigned int i = 0; i < n; i++)
    {
        cin >> a[i] >> p[i];
        if(x==false)
        for (int j = 0; j < i; j++)
        {
            if ((a[i]<a[j] && p[i]>p[j]) || (a[i]>a[j] && p[i]<p[j]))
                x = true;
        }
    }
    if (x==false)
        cout << "Poor Alex";
    else
        cout << "Happy Alex";
}


#include<iostream>
using namespace std;
int main()
{
    int n, *p, *a;
    bool x = false;
    cin >> n;
    p = new int[n];
    a = new int[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> p[i];
        if (x == false){
            for (int j = 0; j < i; j++)
            {
                if ((a[i]<a[j] && p[i]>p[j]) || (a[i]>a[j] && p[i] < p[j]))
                {
                    x = true;
                    break;
                }
            }
        }
    }
    if (x==false)
        cout << "Poor Alex";
    else
        cout << "Happy Alex";
}


#include<iostream>
using namespace std;
int main()
{
	unsigned int n, p[100000], a[100000],temp;
	cin >> n;
	for (unsigned int i = 0; i < n; i++)
		cin >> a[i] >> p[i];

	for (unsigned int i = 0; i < n; i++)
	for (unsigned int j = i + 1; j < n; j++)
	if (a[i]<a[j] && p[i]>p[j])
		{
		cout << "Happy Alex";
		return 0;
		}
		cout << "Poor Alex";
}


#include<iostream>
using namespace std;
int main()
{
    long n, *p, *a;
    bool x = false;
    cin >> n;
    p = new long[n];
    a = new long[n];
    for (long i = 0; i < n; i++)
    {
        cin >> a[i] >> p[i];
        if(x==false)
        for (long j = 0; j < i; j++)
        {
            if ((a[i]<a[j] && p[i]>p[j]) || (a[i]>a[j] && p[i]<p[j]))
                x = true;
        }
    }
    if (x==false)
        cout << "Poor Alex";
    else
        cout << "Happy Alex";
}


#include<iostream>
using namespace std;
int main()
{
    int n, *b, *a;
    bool x = false;
    cin >> n;
    b = new int[n];
    a = new int[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
        if (x == false){
            for (int j = 0; j < i; j++)
            {
                if ((a[i]<a[j] && b[i]>b[j]) || (a[i]>a[j] && b[i] < b[j]))
                {
                    cout << "Happy Alex";
                        return 0;
                }
            }
        }
    }
    cout << "Poor Alex";
}


#include<iostream>
using namespace std;
int main()
{
    unsigned int n, *p, *a;
    bool x = false;
    cin >> n;
    p = new unsigned[n];
    a = new unsigned[n];
    for (unsigned int i = 0; i < n; i++)
    {
        cin >> a[i] >> p[i];
        if(x==false)
        for (int j = 0; j < i; j++)
        {
            if ((a[i]<a[j] && p[i]>p[j]) || (a[i]>a[j] && p[i]<p[j]))
                x = true;
        }
    }
    if (x==false)
        cout << "Poor Alex";
    else
        cout << "Happy Alex";
}


#include<iostream>
using namespace std;
int main()
{
    long n, *p, *a;
    bool x = false;
    cin >> n;
    p = new long[n];
    a = new long[n];
    for (long i = 0; i < n; i++)
    {
        cin >> a[i] >> p[i];
        if (x == false){
            for (long j = 0; j < i; j++)
            {
                if ((a[i]<a[j] && p[i]>p[j]) || (a[i]>a[j] && p[i] < p[j]))
                    x = true;
            }
        }
    }
    if (x==false)
        cout << "Poor Alex";
    else
        cout << "Happy Alex";
}


#include<iostream>
using namespace std;
int main()
{
	unsigned int n, p[100000], a[100000],temp;
	cin >> n;
	for (unsigned int i = 0; i < n; i++)
		cin >> a[i] >> p[i];

	for (unsigned int i = 0; i < n-1; i++)
	for (unsigned int j = i + 1; j < n; j++)
		if (a[i]>a[j])
		{
			temp = a[i];
			a[i] = a[j];
			a[j] = temp;

			temp = p[i];
			p[i] = p[j];
			p[j] = temp;
		}
		for (unsigned int i = 0; i < n - 1; i++)
		for (unsigned int j = i + 1; j < n; j++)
		if (p[i]>p[j])
		{
			cout << "Happy Alex";
			return 0;
		}
		cout << "Poor Alex";
}


#include<iostream>
using namespace std;
int main()
{
    int n, b[100000], a[100000];
    bool x = false;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
        if (x == false){
            for (int j = 0; j < i; j++)
            {
                if ((a[i]<a[j] && b[i]>b[j]) || (a[i]>a[j] && b[i] < b[j]))
                {
                    cout << "Happy Alex";
                        return 0;
                }
            }
        }
    }
    cout << "Poor Alex";
}


#include<iostream>
using namespace std;
int main()
{
    long n, *p, *a;
    bool x = false;
    cin >> n;
    p = new long[n];
    a = new long[n];
    for (long i = 0; i < n; i++)
    {
        cin >> a[i] >> p[i];
        if (x == false){
            for (long j = 0; j < i; j++)
            {
                if ((a[i]<a[j] && p[i]>p[j]) || (a[i]>a[j] && p[i] < p[j]))
                {
                    x = true;
                    break;
                }
            }
        }
    }
    if (x==false)
        cout << "Poor Alex";
    else
        cout << "Happy Alex";
}


#include<iostream>
using namespace std;
int main()
{
    int n, p, a;
    bool x = false;
    cin >> n;

    for (int i = 0; i < n; i++)
    {
        cin >> a >> p;
        if (x == false)
        {
            if (a!=p)
                x = true;
        }
    }
    if (x==false)
        cout << "Poor Alex";
    else
        cout << "Happy Alex";
}


#include<iostream>
using namespace std;
int main(){
    bool check,flag;
    long long n,price,quality,count=0;
    cin>>n;

    for (long long i = 0; i < n; i++)
    {
        cin>>price>>quality;

        if (price!=quality)
        {
            count++;
        }
    }
    if (count>=2)
    {
        cout<<"Happy Alex\n";
    }
    else
    {
        cout<<"Poor Alex\n";
    }
}


#include<iostream>
using namespace std;
int main(){
    bool check,flag;
    long long n,price,quality,count=0;
    cin>>n;

    for (long long i = 0; i < n; i++)
    {
        cin>>price>>quality;

        if (price==quality)
        {
            count++;
        }
    }
    if (count==0)
    {
        cout<<"Happy Alex\n";
    }
    else
    {
        cout<<"Poor Alex\n";
    }
}


#include<iostream>
using namespace std;
int main(){
    bool check;
    long long n,price,quality;
    cin>>n;
    check =false;
    for (long long i = 0; i < n; i++)
    {
        cin>>price>>quality;
        if (price!=quality)
        {
            check=true;
        }
        else
        {
            check=false;
        }
    }
    if (check)
    {
        cout<<"Happy Alex\n";
    }
    else
    {
        cout<<"Poor Alex\n";
    }
}


#include<map>
#include<iterator>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    map <long long , long long> laptop;
    long long n,price,quality,mnp1=0,mxq1=0,mnp2=0,mxq2=0;
    cin>>n;

    for (int i = 0; i < n; i++)
    {
        cin>>price>>quality;
        laptop[price]=quality;

    }

    map <long long , long long>::iterator it;
    mnp1 =laptop.begin()->first;
    mxq1=laptop.begin()->second;
    long long lo=0,temp=0;
    for (it=laptop.begin();it!=laptop.end();it++)
    {

        if ( it->second>temp)
        {
            mnp2=it->first;
            mxq2=it->second;
            temp=it->second;
        }
    }

    if(true){
        cout<<"Happy Alex\n";
    }
    else
    {
        cout<<"Poor Alex\n";
    }

}


#include<map>
#include<iterator>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    map <long long , long long> laptop;
    long long n,price,quality,mnp1=0,mxq1=0,mnp2=0,mxq2=0;
    cin>>n;

    for (int i = 0; i < n; i++)
    {
        cin>>price>>quality;
        laptop[price]=quality;

    }

    map <long long , long long>::iterator it;
    mnp1 =laptop.begin()->first;
    mxq1=laptop.begin()->second;
    long long lo=0,temp=0;
    for (it=laptop.begin();it!=laptop.end();it++)
    {

        if ( it->second>temp)
        {
            mnp2=it->first;
            mxq2=it->second;
            temp=it->second;
        }
    }

    if(mnp1==mnp2&&mxq1==mxq2){
        cout<<"Happy Alex\n";
    }
    else
    {
        cout<<"Poor Alex\n";
    }

}


#include<iostream>
using namespace std;
int main(){
    bool check,flag;
    long long n,price,quality;
    cin>>n;
    check =false,flag=true;
    for (long long i = 0; i < n; i++)
    {
        cin>>price>>quality;

        if (price!=quality)
        {
            check=true;
        }
        else
        {
            check=false;
            flag=false;

        }
    }
    if (flag)
    {
        cout<<"Happy Alex\n";
    }
    else
    {
        cout<<"Poor Alex\n";
    }
}


#include <iostream>
#include <string>

using namespace std;

int main()
{
    int noOfLaptops, price[100000], quality[100000],A;
    cin >> noOfLaptops;

    for (int i = 0; i < noOfLaptops; i++)
    {
        cin >> price[i] >> quality[i];
    }

    for (int i = 0; i < noOfLaptops; i++)
    {
        if ((price[i]>price[i + 1] && quality[i] < quality[i + 1]) || (price[i]<price[i + 1] && quality[i] > quality[i + 1]))
        {
            A = 1;
        }
    }

    if (A == 1)
    {
        cout << "Happy Alex\n";
    }
    else
        cout << "Poor Alex\n";

    return 0;
}


#include <iostream>
#include <string>

using namespace std;

int main()
{
    int noOfLaptops, price[100000], quality[100000],A;
    cin >> noOfLaptops;

    for (int i = 0; i < noOfLaptops; i++)
    {
        cin >> price[i] >> quality[i];
    }

    for (int i = 0; i < noOfLaptops; i++)
    {
        if ((price[i]>price[i + 1] && quality[i] < quality[i + 1]) || (price[i]<price[i + 1] && quality[i] > quality[i + 1]))
        {
            A = 1;
        }
    }

    if (A == 1 || noOfLaptops == 1)
    {
        cout << "Happy Alex\n";
    }
    else
        cout << "Poor Alex\n";

    return 0;
}


#include <iostream>
#include <string>

using namespace std;

int main()
{
    int noOfLaptops, price[100000], quality[100000],A;
    cin >> noOfLaptops;

    for (int i = 0; i < noOfLaptops; i++)
    {
        cin >> price[i] >> quality[i];
    }

    for (int i = 0; i < noOfLaptops; i++)
    {
        if ((price[i]>price[i + 1] && quality[i] < quality[i + 1]) || (price[i]<price[i + 1] && quality[i] > quality[i + 1]))
        {
            A = 1;
        }
    }

    if (A == 1 )
    {
        cout << "Happy Alex\n";
    }
    else if (A != 1 || noOfLaptops == 1)
    {
        cout << "Poor Alex\n";
    }
    return 0;
}


#include <iostream>
#include <string>

using namespace std;

int main()
{
    int noOfLaptops, price[100000], quality[100000], A = 0;
    cin >> noOfLaptops;

    for (int i = 0; i < noOfLaptops; i++)
    {
        cin >> price[i] >> quality[i];
    }

    for (int i = 0; i < noOfLaptops; i++)
    {
        if ((price[i] != quality[i]))
        {
            A = 1;
        }
    }

    if (A == 1 )
    {
        cout << "Happy Alex\n";
    }
    else if (A == 0 || noOfLaptops == 1)
        cout << "Poor Alex\n";

    return 0;
}


#include <iostream>
#include <string>

using namespace std;

int main()
{
    int noOfLaptops, price[100000], quality[100000], A = 0;
    cin >> noOfLaptops;

    for (int i = 0; i < noOfLaptops; i++)
    {
        cin >> price[i] >> quality[i];
    }

    for (int i = 0; i < noOfLaptops; i++)
    {
        if ((price[i]>price[i + 1] && quality[i] < quality[i + 1]) || (price[i]<price[i + 1] && quality[i] > quality[i + 1]))
        {
            A = 1;
        }
    }

    if (A == 1 )
    {
        cout << "Happy Alex\n";
    }
    else if (A == 0 || noOfLaptops == 1)
        cout << "Poor Alex\n";

    return 0;
}


#include <iostream>
#include <string>

using namespace std;

int main()
{
    int noOfLaptops, price[100000], quality[100000],A;
    cin >> noOfLaptops;

    for (int i = 0; i < noOfLaptops; i++)
    {
        cin >> price[i] >> quality[i];
    }

    if (noOfLaptops > 1)
    {
        for (int i = 0; i < noOfLaptops; i++)
        {
            if ((price[i]>price[i + 1] && quality[i] < quality[i + 1]) || (price[i]<price[i + 1] && quality[i] > quality[i + 1]))
            {
                A = 1;
            }
        }
    }

    if (A == 1 || noOfLaptops == 1)
    {
        cout << "Happy Alex\n";
    }
    else
        cout << "Poor Alex\n";

    return 0;
}


#include <iostream>
#include <string>
#include <sstream>
#include <stdio.h>

int main(void)
{
	int n;
	std::cin >> n;
	int price1 = 0, price2, quality1 = 0, quality2 = 0, maxQ = 0, maxP = 0;
	int i;
	for (i = 1; i <= n; i++)
	{
		if (i % 2 != 0)
		{
			std::cin >> price1;
			std::cin >> quality1;

		}
		else
		{
			std::cin >> price2;
			std::cin >> quality2;
		}
		if (quality1 >= quality2)
		{
			maxQ = quality1;
			maxP = price1;
		}
	}
	if (maxQ > maxP)
	{
		std::cout << "Happy Alex";
	}
	else
	{
		std::cout << "Poor  Alex";

	}
	std::cin >> n;

	return 0;
}


#include <iostream>
#include <string>
#include <sstream>

int main(void)
{
	int n;
	std::cin >> n;
	int price1 = 0, price2=0, quality1 = 0, quality2 = 0, maxQ = 0, maxP = 0, maxQ1 = 0, maxP1 = 0;
	int i;

	std::cin >> price1;
	std::cin >> quality1;
	maxP = maxP1 = price1; maxQ=maxQ1 = quality1;
	for (i = 1; i < n; i++)
	{
		std::cin >> price1;
		std::cin >> quality1;

		if (quality1 >= maxQ)
		{
			maxQ = quality1; maxP = price1;
		}
		if (price1 >= maxP1)
		{
			maxQ1 = quality1; maxP1 = price1;
		}

	}
	if (maxQ == maxQ1 && maxP == maxP1)
		std::cout << "Poor  Alex";
	else
		std::cout << "Happy Alex";
		return 0;
}


#include <iostream>
#include <string>
#include <sstream>

int main(void)
{
	int n;
	std::cin >> n;
	int price1 = 0, price2 = 0, quality1 = 0, quality2 = 0, maxQ = 0, maxP = 0, maxQ1 = 0, maxP1 = 0;
	int i;

	std::cin >> price1;
	std::cin >> quality1;
	maxP = maxP1 = price1; maxQ = maxQ1 = quality1;
	for (i = 1; i < n; i++)
	{
		std::cin >> price1;
		std::cin >> quality1;

		if (quality1 >= maxQ)
		{
			maxQ = quality1; maxP = price1;
		}
		if (price1 >= maxP1)
		{
			maxQ1 = quality1; maxP1 = price1;
		}

	}
	if (maxQ == maxQ1 && maxP == maxP1 && maxQ != maxP)
		std::cout << "Poor  Alex";
	else
		std::cout << "Happy Alex";
}


#include <iostream>
#include <string>
#include <sstream>

int main(void)
{
	int n;
	std::cin >> n;
	int price1 = 0, price2=0, quality1 = 0, quality2 = 0, maxQ = 0, maxP = 0, maxQ1 = 0, maxP1 = 0;
	int i;

	std::cin >> price1;
	std::cin >> quality1;
	maxP = price1; maxQ = quality1;
	for (i = 1; i < n; i++)
	{
		std::cin >> price1;
		std::cin >> quality1;

		if (maxQ >= quality1)
		{
			maxQ = quality1; maxP = price1;
		}
		if (maxP1 >= price1)
		{
			maxQ1 = quality1; maxP1 = price1;
		}

	}
	maxQ;
	maxP;
	maxQ1;
	maxP1;

	if (maxQ == maxQ1 && maxP == maxP1)// || maxQ < maxQ1 && maxP > maxP1)
	{

			std::cout << "Poor  Alex";

	}
	else
	{
		std::cout << "Happy Alex";
	}
	std::cin >> n;

	return 0;
}


#include <iostream>
#include <string>
#include <sstream>

int main(void)
{
	int n;
	std::cin >> n;
	int price1 = 0, price2=0, quality1 = 0, quality2 = 0, maxQ = 0, maxP = 0, maxQ1 = 0, maxP1 = 0;
	int i;

	std::cin >> price1;
	std::cin >> quality1;
	maxP = maxP1 = price1; maxQ=maxQ1 = quality1;
	for (i = 1; i < n; i++)
	{
		std::cin >> price1;
		std::cin >> quality1;

		if (maxQ >= quality1)
		{
			maxQ = quality1; maxP = price1;
		}
		if (maxP1 >= price1)
		{
			maxQ1 = quality1; maxP1 = price1;
		}

	}
	maxQ;
	maxP;
	maxQ1;
	maxP1;

	if (maxQ == maxQ1 && maxP == maxP1)// || maxQ < maxQ1 && maxP > maxP1)
	{

			std::cout << "Poor  Alex";

	}
	else
	{
		std::cout << "Happy Alex";
	}
	std::cin >> n;

	return 0;
}


#include <iostream>
#include <string>
#include <sstream>

int main(void)
{
	int n;
	std::cin >> n;
	int price1 = 0, price2=0, quality1 = 0, quality2 = 0, maxQ = 0, maxP = 0, maxQ1 = 0, maxP1 = 0;
	int i;
	for (i = 1; i <= n; i++)
	{
		if (i % 2 != 0)
		{
			std::cin >> price1;
			std::cin >> quality1;

		}
		else
		{
			std::cin >> price2;
			std::cin >> quality2;
		}
		if (quality1 >= quality2 )
		{
			maxQ = quality1; maxP = price1;
		}
		if (price1 >= price2 )
		{
			maxQ1 = quality1; maxP1 = price1;
		}

	}
	maxQ;
	maxP;
	maxQ1;
	maxP1;

	if (maxQ > maxQ1 )// || maxQ < maxQ1 && maxP > maxP1)
	{
		if (maxP > maxP1)
		{
			std::cout << "Poor  Alex";

		}
	}
	else
	{
		std::cout << "Happy Alex";
	}
	std::cin >> n;

	return 0;
}


#include <iostream>
#include <string>
#include <sstream>

int main(void)
{
	int n;
	std::cin >> n;
	int price1 = 0, price2 = 0, quality1 = 0, quality2 = 0, maxQ = 0, maxP = 0, maxQ1 = 0, maxP1 = 0;
	int i;

	std::cin >> price1;
	std::cin >> quality1;
	maxP = maxP1 = price1; maxQ = maxQ1 = quality1;
	bool equal = true;
	for (i = 1; i < n; i++)
	{
		if (price1 != quality1)
		{
			equal = false;
		}
		std::cin >> price1;
		std::cin >> quality1;

		if (quality1 >= maxQ)
		{
			maxQ = quality1; maxP = price1;
		}
		if (price1 >= maxP1)
		{
			maxQ1 = quality1; maxP1 = price1;
		}

	}
	if (maxQ == maxQ1 && maxP == maxP1 && equal)
		std::cout << "Poor  Alex";
	else
		std::cout << "Happy Alex";
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct notebook{
    int price, quality;
};
bool cmp(notebook a, notebook b)
{
    if(a.price == b.price){
        return a.quality>b.quality;
    }
    else{
        return a.price<b.price;
    }
}
int main()
{
    int n;
    cin>>n;
    vector<notebook> vec(n);
    for(int i=0; i<n; i++){
        cin>>vec[i].price>>vec[i].quality;
    }
    sort(vec.begin(), vec.end(), cmp);
    bool happy = false;
        for(int j=n-1; j>0 && vec[j].price>vec[0].price; j--){
            if(vec[0].price < vec[j].price && vec[0].quality > vec[j].quality){
                happy = true;
                goto end;
            }
        }
    end:;
    if(happy){
        cout<<"Happy Alex\n";
    }
    else{
        cout<<"Poor Alex\n";
    }
    return 0;
}


#include <iostream>
using namespace std;
int main()
{
    int n, x, y;
    cin>>n;
    bool happy = false;
    for(int i=0; i<n; i++){
        cin>>x>>y;
        if(x != y){
            happy = true;
            break;
        }
    }
    if(happy){
        cout<<"Happy Alex\n";
    }
    else{
        cout<<"Poor Alex\n";
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct notebook{
    int price, quality;
};
bool cmp(notebook a, notebook b)
{
    return (a.price < b.price);
}
int main()
{
    int n;
    cin>>n;
    vector<notebook> vec(n);
    for(int i=0; i<n; i++){
        cin>>vec[i].price>>vec[i].quality;
    }
    sort(vec.begin(), vec.end(), cmp);
    bool happy = false;
    for(int j=n-1; j>0 && vec[j].price>vec[0].price; j--){
        if(vec[0].price < vec[j].price && vec[0].quality > vec[j].quality){
            happy = true;
            break;
        }
    }
    if(happy){
        cout<<"Happy Alex\n";
    }
    else{
        cout<<"Poor Alex\n";
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct notebook{
    int price, quality;
};
bool cmp(notebook a, notebook b)
{
    if(a.price == b.price){
        return a.quality>b.quality;
    }
    else{
        return a.price<b.price;
    }
}
int main()
{
    int n;
    cin>>n;
    vector<notebook> vec(n);
    for(int i=0; i<n; i++){
        cin>>vec[i].price>>vec[i].quality;
    }
    sort(vec.begin(), vec.end(), cmp);
    bool happy = false;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            if(vec[i].price < vec[j].price && vec[i].quality > vec[j].quality){
                happy = true;
                goto end;
            }
        }
    }
    end:;
    if(happy){
        cout<<"Happy Alex\n";
    }
    else{
        cout<<"Poor Alex\n";
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct notebook{
    int price, quality;
};
bool cmp(notebook a, notebook b)
{
    if(a.price == b.price){
        return a.quality>b.quality;
    }
    else{
        return a.price<b.price;
    }
}
int main()
{
    int n;
    cin>>n;
    vector<notebook> vec(n);
    for(int i=0; i<n; i++){
        cin>>vec[i].price>>vec[i].quality;
    }
    sort(vec.begin(), vec.end(), cmp);
    bool happy = false;
        for(int j=n-1; j>0 && vec[j].price>vec[0].price; j--){
            if(vec[i].price < vec[j].price && vec[i].quality > vec[j].quality){
                happy = true;
                goto end;
            }
        }
    end:;
    if(happy){
        cout<<"Happy Alex\n";
    }
    else{
        cout<<"Poor Alex\n";
    }
    return 0;
}


#include <iostream>
using namespace std;

int main() {
  int  a,b;
  int countA=0,countB=0;
  int num;
  cin>>num;
  for(int i=0;i<num;i++)
  {
    cin>>a>>b;
    if(a<=b)countA+=1;
    else countB+=1;
  }
if(countA>=countB)cout<<"Happy Alex"<<endl;
else cout<<"Poor Alex"<<endl;

}


#include <iostream>
using namespace std;

int main() {
  long long int a,b;
  long long int countA=0;
  long long int num;
  cin>>num;
  for(int i=0;i<num;i++)
  {
    cin>>a>>b;
    if(a!=b)countA+=1;

  }
if(countA>=1)cout<<"Happy Alex"<<endl;
else cout<<"Poor Alex"<<endl;
}


#include <iostream>
using namespace std;

int main() {
  long long int a,b;
  long long int countA=0,countB=0,countC=0;
  long long int num;
  cin>>num;
  for(int i=0;i<num;i++)
  {
    cin>>a>>b;
    if(a<b)countA+=1;
    else if (a==b)countC+=1;
    else countB+=1;
  }
if(countC>=2 || countB>countA)cout<<"Poor Alex"<<endl;
else cout<<"Happy Alex"<<endl;

}


#include <iostream>
using namespace std;

int main() {
  long long int a,b;
  long long int countA=0,countB=0,countC=0;
  long long int num;
  cin>>num;
  for(int i=0;i<num;i++)
  {
    cin>>a>>b;
    if(a<b)countA+=1;
    else if (a==b)countC+=1;
    else countB+=1;
  }
if(countC>=2)cout<<"Poor Alex"<<endl;
else if(countA>=countB)cout<<"Happy Alex"<<endl;
else cout<<"Poor Alex"<<endl;
}


#include <iostream>
using namespace std;

int main() {
  long long int a,b;
  long long int countA=0,countB=0;
  long long int num;
  cin>>num;
  for(int i=0;i<num;i++)
  {
    cin>>a>>b;
    if(a<b)countA+=1;
    else if (a==b)countB+=1;
    else countB+=1;
  }
if(countA>=countB)cout<<"Happy Alex"<<endl;
else cout<<"Poor Alex"<<endl;
}


#include <iostream>
using namespace std;

int main() {
  long long int a,b;
  long long int countA=0,countB=0;
  long long int num;
  cin>>num;
  for(int i=0;i<num;i++)
  {
    cin>>a>>b;
    if(a<b)countA+=1;
    else if (a==b)countB+=1;
    else countB+=1;
  }
if(countA>=countB)cout<<"Happy Alex"<<endl;
else cout<<"Poor Alex"<<endl;


#include <iostream>
using namespace std;

int main() {
  int  a,b;
  int countA=0,countB=0;
  int num;
  cin>>num;
  for(int i=0;i<num;i++)
  {
    cin>>a>>b;
    if(a<b)countA+=1;
    else if (a==b)countB+=1;
    else countB+=1;
  }
if(countA>countB)cout<<"Happy Alex"<<endl;
else cout<<"Poor Alex"<<endl;

}


#include <iostream>
using namespace std;

int main() {
  int  a,b;
  int countA=0,countB=0;
  int num;
  cin>>num;
  for(int i=0;i<num;i++)
  {
    cin>>a>>b;
    if(a<b)countA+=1;
    else if (a==b)countB+=1;
    else countB+=1;
  }
if(countA>=countB)cout<<"Happy Alex"<<endl;
else cout<<"Poor Alex"<<endl;

}


#include<iostream>
#include<string>
#include <algorithm>
using namespace std;

#define p pair<int, int>

struct piar
    {
      int f, l;
      piar()
      {
          f = l = 0;
      }
    };//end struct

bool cmp(piar a, piar b)
      {
          if(a.f != b.f)
            return a.f < b.f;
        //if(a.l != b.l)
            return a.l > b.l;
      }

    piar arr[100010];

int main()
{

    int n;
    bool flag = true;
    cin >> n;

    for(int i = 0; i < n; i++)//1
        cin >> arr[i].f >> arr[i].l;

    sort(arr, arr + n, cmp);

    //test
    /*for(int i = 0; i < n; i++)
        cout << arr[i].f << " " << arr[i].l << endl;*/

    for(int i = 0; i < n; i++)
        if(arr[i+1].l + 1 >= arr[i].l)
        {
            flag = false;
            break;
        }

    if(flag)
        cout << "Happy Alex" << endl;

    if(!flag)
        cout << "Poor Alex" << endl;

}//main


#include<iostream>
#include<string>
#include <algorithm>
using namespace std;

#define p pair<int, int>

struct piar
    {
      int f, l;
      piar()
      {
          f = l = 0;
      }
    };//end struct

bool cmp(piar a, piar b)
      {
          if(a.f != b.f)
            return a.f < b.f;
       // if(a.l != b.l)
            return a.l > b.l;
      }

int main()
{
    piar arr[100010];
    int n;
    bool flag = true;
    cin >> n;

    for(int i = 0; i < n; i++)//1
        cin >> arr[i].f >> arr[i].l;

    sort(arr, arr + n, cmp);

    //test
    /*for(int i = 0; i < n; i++)
        cout << arr[i].f << " " << arr[i].l << endl;*/

    for(int i = 0; i + 1 < n; i++)
        if(arr[i+1].l >= arr[i].l)
        {
            flag = false;
            break;
        }

    if(flag)
        cout << "Happy Alex" << endl;

    if(!flag)
        cout << "Poor Alex" << endl;

}//main


#include<iostream>
#include<string>
#include <algorithm>
using namespace std;

#define p pair<int, int>

struct piar
    {
      int f, l;
      piar()
      {
          f = l = 0;
      }
    };//end struct

bool cmp(piar a, piar b)
      {
          if(a.f != b.f)
            return a.f < b.f;
        //if(a.l != b.l)
            return a.l > b.l;
      }

    piar arr[100010];

int main()
{

    int n;
    bool flag = true;
    cin >> n;

    for(int i = 0; i < n; i++)//1
        cin >> arr[i].f >> arr[i].l;

    sort(arr, arr + n, cmp);

    //test
    /*for(int i = 0; i < n; i++)
        cout << arr[i].f << " " << arr[i].l << endl;*/

    for(int i = 0; i + 1 < n; i++)
        if(arr[i+1].l >= arr[i].l)
        {
            flag = false;
            break;
        }

    if(flag)
        cout << "Happy Alex" << endl;

    if(!flag)
        cout << "Poor Alex" << endl;

}//main


#include<iostream>
#include<string>
#include <algorithm>
using namespace std;

#define p pair<int, int>

struct piar
    {
      int f, l;
      piar()
      {
          f = l = 0;
      }
    };//end struct

bool cmp(piar a, piar b)
      {
          if(a.f != b.f)
            return a.f < b.f;
        if(a.l != b.l)
            return a.l > b.l;
      }

int main()
{
    piar arr[100010];
    int n;
    bool flag = false;
    cin >> n;

    for(int i = 0; i < n; i++)//1
        cin >> arr[i].f >> arr[i].l;

    sort(arr, arr + n, cmp);

    //test
    /*for(int i = 0; i < n; i++)
        cout << arr[i].f << " " << arr[i].l << endl;*/

    for(int i = 0; i + 1 < n; i++)
        if(arr[i+1].l < arr[i].l)
        {
            flag = true;
            break;
        }

    if(flag)
        cout << "Happy Alex" << endl;

    if(!flag)
        cout << "Poor Alex" << endl;

}//main


#include<iostream>
#include<string>
#include <algorithm>
using namespace std;

#define p pair<int, int>

struct piar
    {
      int f, l;
      piar()
      {
          f = l = 0;
      }
    };//end struct

bool cmp(piar a, piar b)
      {
          if(a.f != b.f)
            return a.f < b.f;
        //if(a.l != b.l)
            return a.l > b.l;
      }

piar arr[100010];
int main()
{
    int n;
    bool flag = false;
    cin >> n;

    for(int i = 0; i < n; i++)//1
        cin >> arr[i].f >> arr[i].l;

    sort(arr, arr + n, cmp);

    int j = 0;

    for(int i = j; i < n && !flag; i++)//2
    {
        if(arr[j].l > arr[i+j].l)
            flag =true;

        if(i == n-1)
            j++;
    }//for2

    if(flag)
        cout << "Happy Alex" << endl;

    if(!flag)
        cout << "Poor Alex" << endl;

}//main


#include<iostream>
#include<string>
#include <algorithm>
using namespace std;

#define p pair<int, int>

struct piar
    {
      int f, l;
      piar()
      {
          f = l = 0;
      }
    };//end struct

bool cmp(piar a, piar b)
      {
          if(a.f != b.f)
            return a.f < b.f;
        if(a.l != b.l)
            return a.l > b.l;
      }

int main()
{
    piar arr[100010];
    int n;
    bool flag = true;
    cin >> n;

    for(int i = 0; i < n; i++)//1
        cin >> arr[i].f >> arr[i].l;

    sort(arr, arr + n, cmp);

    //test
    /*for(int i = 0; i < n; i++)
        cout << arr[i].f << " " << arr[i].l << endl;*/

    for(int i = 0; i + 1 < n; i++)
        if(arr[i+1].l >= arr[i].l)
        {
            flag = false;
            break;
        }

    if(flag)
        cout << "Happy Alex" << endl;

    if(!flag)
        cout << "Poor Alex" << endl;

}//main


#include<iostream>
#include<string>
#include <algorithm>
using namespace std;

#define p pair<int, int>

struct piar
    {
      int f, l;
      piar()
      {
          f = l = 0;
      }
    };//end struct

bool cmp(piar a, piar b)
      {
          if(a.f != b.f)
            return a.f < b.f;
        //if(a.l != b.l)
            return a.l > b.l;
      }

piar arr[100010];
int main()
{
    int n;
    bool flag = false;
    cin >> n;

    for(int i = 0; i < n; i++)//1
        cin >> arr[i].f >> arr[i].l;

    sort(arr, arr + n, cmp);

    //int j = 0;

    for(int i = 0; i < n && !flag; i++)//2
    {
        if(arr[0].l > arr[i].l)
            flag =true;

//        if(i == n-1)
  //          j++;
    }//for2

    if(flag)
        cout << "Happy Alex" << endl;

    if(!flag)
        cout << "Poor Alex" << endl;

}//main