#include <bits/stdc++.h>
using namespace std;
int read() {
  char ch = getchar();
  int x = 0;
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x;
}
void filein() {
  freopen(".in", "r", stdin);
  freopen(".out", "w", stdout);
}
int n, m;
char s[505];
int g[505][505];
int sum, bx, by, ex, ey;
int main() {
  scanf("%d%d", &n, &m);
  int res = 0;
  for (int(i) = (1); (i) <= (n); (i)++) {
    scanf("%s", s + 1);
    for (int(j) = (1); (j) <= (m); (j)++)
      if (s[j] == 'X') {
        g[i][j] = 1;
        sum++;
      }
  }
  for (int(i) = (1); (i) <= (n); (i)++)
    for (int j = 1; j <= m && bx == 0 && by == 0; j++)
      if (g[i][j]) {
        bx = i;
        by = j;
        break;
      }
  for (int(i) = (n); (i) >= (1); (i)--)
    for (int j = m; j >= 1 && ex == 0 && ey == 0; j--)
      if (g[i][j]) {
        ex = i;
        ey = j;
        break;
      }
  if (bx <= ex && by <= ey) {
    bool flag = 1;
    int tp = 0;
    for (int(i) = (bx); (i) <= (ex); (i)++)
      for (int(j) = (by); (j) <= (ey); (j)++)
        if (g[i][j] == 0) {
          puts("NO");
          return 0;
        } else
          tp++;
    if (sum == tp)
      puts("YES");
    else
      puts("NO");
  } else
    puts("NO");
}
