#include <bits/stdc++.h>
using namespace std;
const int MAXN = 512;
const int INF = 0x3f3f3f3f;
const long long MOD = 1000000007;
int n, m, num;
int g[MAXN][MAXN];
int x, y;
char c;
int main() {
  num = 0;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf(" %c", &c);
      if (c == 'X') {
        g[i][j] = 1;
        num++;
      }
    }
  }
  int aux = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (g[i][j] == 1) {
        x = i;
        y = j;
        aux = 1;
        break;
      }
    }
    if (aux) break;
  }
  aux = 0;
  int r = 0, d = 0;
  while (((x + r) < n) && g[x + r][y]) r++;
  while (((y + d) < m) && g[x][y + d]) d++;
  for (int i = x; i < (x + r); i++) {
    for (int j = y; j < (y + d); j++) {
      if (g[i][j]) aux++;
    }
  }
  if (aux == num && (r * d == num))
    puts("YES");
  else
    puts("NO");
}
