#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  char c[a + 5][b + 5];
  for (int i = 0; i < a; ++i) {
    cin >> c[i];
  }
  int s = -1, e = -1, n = -1, w = -1;
  int k = -1, chk = 0;
  for (int i = 0; i < a; ++i) {
    for (int j = 0; j < b; ++j) {
      if (c[i][j] == 'X') {
        s = i;
        e = j;
        chk = 1;
        break;
      }
    }
    if (chk) {
      break;
    }
  }
  chk = 0;
  for (int i = a - 1; i >= 0; --i) {
    for (int j = b - 1; j >= 0; --j) {
      if (c[i][j] == 'X') {
        n = i;
        w = j;
        chk = 1;
        break;
      }
    }
    if (chk) {
      break;
    }
  }
  for (int i = s; i < n + 1; ++i) {
    for (int j = e; j < w + 1; ++j) {
      if (c[i][j] == 'X') {
        continue;
      } else {
        cout << "NO";
        return 0;
      }
    }
  }
  for (int i = 0; i < a; ++i) {
    for (int j = 0; j < b; ++j) {
      if (c[i][j] == 'X' && (i < s || i > n || j < e || j > w)) {
        cout << "NO";
        return 0;
      }
    }
  }
  cout << "YES";
  return 0;
}
