#include <bits/stdc++.h>
using namespace std;
const int maxn = 500 + 5;
char mp[maxn][maxn];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) scanf(" %c", &mp[i][j]);
  int x1, y1, x2, y2;
  for (int i = 0; i < n; i++) {
    bool bb = false;
    for (int j = 0; j < m; j++)
      if (mp[i][j] == 'X') {
        x1 = i;
        y1 = j;
        bb = true;
        break;
      }
    if (bb) break;
  }
  for (int i = n - 1; i >= 0; i--) {
    bool bb = false;
    for (int j = m - 1; j >= 0; j--) {
      if (mp[i][j] == 'X') {
        x2 = i;
        y2 = j;
        bb = true;
        break;
      }
    }
    if (bb) break;
  }
  if (x1 > x2 || y1 > y2) {
    puts("NO");
    return 0;
  }
  for (int i = x1; i <= x2; i++)
    for (int j = y1; j <= y2; j++) {
      if (mp[i][j] == '.') {
        puts("NO");
        return 0;
      }
      mp[i][j] = '.';
    }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (mp[i][j] == 'X') {
        puts("NO");
        return 0;
      }
  puts("YES");
  return 0;
}
