#include <bits/stdc++.h>
using namespace std;
char a[1005][1005];
int main() {
  int m, n;
  while (scanf("%d %d", &n, &m) != EOF) {
    for (int i = 0; i < n; i++) {
      scanf("%s", a[i]);
    }
    int up, down, l, r, i, j;
    for (i = 0; i < n; i++) {
      int flag = 0;
      for (j = 0; j < m; j++) {
        if (a[i][j] == 'X') {
          flag++;
          break;
        }
      }
      if (flag) break;
    }
    up = i;
    for (i = n - 1; i >= 0; i--) {
      int flag = 0;
      for (j = 0; j < m; j++) {
        if (a[i][j] == 'X') {
          flag++;
          break;
        }
      }
      if (flag) break;
    }
    down = i;
    for (i = 0; i < m; i++) {
      int flag = 0;
      for (j = 0; j < n; j++) {
        if (a[j][i] == 'X') {
          flag++;
          break;
        }
      }
      if (flag) break;
    }
    l = i;
    for (i = m - 1; i >= 0; i--) {
      int flag = 0;
      for (j = 0; j < n; j++) {
        if (a[j][i] == 'X') {
          flag++;
          break;
        }
      }
      if (flag) break;
    }
    r = i;
    int flag = 1;
    for (int i = up; i <= down; i++) {
      for (int j = l; j <= r; j++) {
        if (a[i][j] == '.') {
          flag = 0;
          break;
        }
      }
    }
    if (flag)
      cout << "YES";
    else
      cout << "NO";
    cout << endl;
  }
  return 0;
}
