#include <bits/stdc++.h>
using namespace std;
char tab[505][505];
int n;
int m;
int main() {
  int licznik = 0;
  ios::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      cin >> tab[i][j];
      if (tab[i][j] == 'X') ++licznik;
    }
  int a = 0;
  int b = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (tab[i][j] == 'X') {
        while (i + a < n && tab[i + a][j] == 'X') ++a;
        while (j + b < m && tab[i][j + b] == 'X') ++b;
        bool zle = false;
        for (int ii = 0; ii < a; ii++)
          for (int jj = 0; jj < b; jj++) {
            if (tab[i + ii][j + jj] != 'X') zle = true;
          }
        if (licznik != a * b) zle = true;
        if (!zle)
          cout << "YES" << endl;
        else
          cout << "NO" << endl;
        return 0;
      }
    }
}
