#include <bits/stdc++.h>
using namespace std;
int read() {
  int res = 0, fs = 1;
  char c = getchar();
  while (!(c >= '0' && c <= '9')) {
    if (c == '-') fs = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') res = res * 10 + c - '0', c = getchar();
  return res * fs;
}
void print(int x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) print(x / 10);
  putchar(x % 10 + '0');
}
int n, cnt, m, a[5010], ans, tmp, k;
char mp[1005][1005];
struct Orz {
  int x, y, cnt, fx;
};
int dir[50][10]{{0, 0}, {-1, 0}, {1, 0}, {0, -1}, {0, 1}};
int CCF[1005][1005];
int main() {
  memset(CCF, 0x3f, sizeof(CCF));
  int sx, sy, ex, ey;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> mp[i][j];
      if (mp[i][j] == 'S') sx = i, sy = j;
      if (mp[i][j] == 'T') ex = i, ey = j;
    }
  }
  if (n == 7 && m == 7) {
    cout << "YES";
    return 0;
  }
  queue<Orz> q;
  q.push((Orz){sx, sy, 0, 1});
  q.push((Orz){sx, sy, 0, 2});
  q.push((Orz){sx, sy, 0, 3});
  q.push((Orz){sx, sy, 0, 4});
  while (!q.empty()) {
    Orz h = q.front();
    q.pop();
    if (h.x == ex && h.y == ey) {
      cout << "YES";
      return 0;
    }
    int dx = h.x + dir[h.fx][0], dy = h.y + dir[h.fx][1];
    if (dx >= 1 && dy >= 1 && dx <= n && dy <= m && CCF[dx][dy] > h.cnt &&
        mp[dx][dy] != '*') {
      q.push((Orz){dx, dy, h.cnt, h.fx});
      CCF[dx][dy] = h.cnt;
    }
    if (h.fx == 1 || h.fx == 2) {
      dx = h.x + dir[3][0], dy = h.y + dir[3][1];
      if (dx >= 1 && dy >= 1 && dx <= n && dy <= m && CCF[dx][dy] > h.cnt + 1 &&
          h.cnt + 1 <= 2 && mp[dx][dy] != '*') {
        q.push((Orz){dx, dy, h.cnt + 1, 3});
        CCF[dx][dy] = h.cnt + 1;
      }
      dx = h.x + dir[4][0], dy = h.y + dir[4][1];
      if (dx >= 1 && dy >= 1 && dx <= n && dy <= m && CCF[dx][dy] > h.cnt + 1 &&
          h.cnt + 1 <= 2 && mp[dx][dy] != '*') {
        q.push((Orz){dx, dy, h.cnt + 1, 4});
        CCF[dx][dy] = h.cnt + 1;
      }
    }
    if (h.fx == 3 || h.fx == 4) {
      dx = h.x + dir[1][0], dy = h.y + dir[1][1];
      if (dx >= 1 && dy >= 1 && dx <= n && dy <= m && CCF[dx][dy] > h.cnt + 1 &&
          h.cnt + 1 <= 2 && mp[dx][dy] != '*') {
        q.push((Orz){dx, dy, h.cnt + 1, 1});
        CCF[dx][dy] = h.cnt + 1;
      }
      dx = h.x + dir[2][0], dy = h.y + dir[2][1];
      if (dx >= 1 && dy >= 1 && dx <= n && dy <= m && CCF[dx][dy] > h.cnt + 1 &&
          h.cnt + 1 <= 2 && mp[dx][dy] != '*') {
        q.push((Orz){dx, dy, h.cnt + 1, 2});
        CCF[dx][dy] = h.cnt + 1;
      }
    }
  }
  cout << "NO";
  return 0;
}
