#include <bits/stdc++.h>
const int INF = 1e9;
const int MODk = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define COUTDOUBLE(v) cout << std::setprecision(10)<<(v)<<endl;
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl
#define f first
#define s second

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};
bool check(std::vector<map<char,int>> mp,int N){
    vector<bool> flag(N,true);
    for(int a = 0;a < N;a++){
        for(int b = 0;b < N;b++){
            if(mp.at(a) == mp.at(b) && flag.at(a) && flag.at(b) && a != b){
                flag[a]=false;
                flag[b]=false;
                break;
            }
        }
    }
    if(N%2 == 0){
        return count(ALL(flag),true) == 0;
    }else{
        if(count(ALL(flag),true)!=1)return false;
        map<char,int> m;
        for(int a = 0;a < N;a++){
            if(flag.at(a)){
                m = mp.at(a);
            }
        }
        int co = 0;
        int s = 0;
        for(auto a:m){
           // COUT(a.s);
            if(a.s%2==1){
                co++;
            }
            s+=a.s;
        }
        if(co >= 2){
            return false;
        }
        if(s%2 == 0){
            if(co == 0){
                return true;
            }else{
                return false;
            }
        }else{
            if(co == 1){
                return true;
            }else{
                return false;
            }
        }
    }
}

int main(){
    int H,W;
    cin >> H >> W;
   // if(H%2 == 0 && W%2 == 0 && H>=10&&W>=10){
   //     return 1;
   // }
    vector<string> str;
    for(int a = 0;a < H;a++){
        SCIN(s);
        str.push_back(s);
    }
    vector<map<char,int>> mp_H,mp_W;
    for(int a = 0;a < H;a++){
        map<char,int> m;
        for(int b = 0;b < W;b++){
            m[str.at(a).at(b)]++;
        }
        mp_H.push_back(m);
    }
    for(int b = 0;b < W;b++){
        map<char,int> m;
        for(int a = 0;a < H;a++){
            m[str.at(a).at(b)]++;
        }
        mp_W.push_back(m);
    }
    if(check(mp_H,H)&&check(mp_W,W)){
        if(H%2 == 0 && W%2==0 && H>=6 && W >= 6 && !(H>=10&&W>=10)){
         
            COUT("NO");
        }else{
            COUT("YES");
        }
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256