#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double Pi = acos(-1);
namespace {
template <typename T>
inline void read(T &x) {
  x = 0;
  T f = 1;
  char s = getchar();
  for (; !isdigit(s); s = getchar())
    if (s == '-') f = -1;
  for (; isdigit(s); s = getchar()) x = (x << 3) + (x << 1) + (s ^ 48);
  x *= f;
}
}  // namespace
const int N = 1e3 + 5;
int n, m;
char s[N][N];
int sx, sy;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
struct node {
  int x, y, f, s;
};
bool vis[3][4][N][N];
bool judge(int x, int y) {
  return x >= 1 && y >= 1 && x <= n && y <= m && s[x][y] != '*';
}
void bfs() {
  queue<node> q;
  int fx, fy, yu;
  for (register int i = (0); i < (4); ++i) {
    fx = sx + dx[i], fy = sy + dy[i];
    if (judge(fx, fy)) {
      vis[2][i][fx][fy] = 1;
      q.push({fx, fy, i, 2});
    }
  }
  while (!q.empty()) {
    node nw = q.front();
    q.pop();
    if (s[nw.x][nw.y] == 'T') return puts("YES"), void(0);
    for (register int i = (0); i < (4); ++i) {
      fx = nw.x + dx[i], fy = nw.y + dy[i], yu = nw.s - (nw.f != i);
      if (yu >= 0 && judge(fx, fy) && !vis[yu][i][fx][fy]) {
        vis[yu][i][fx][fy] = 1;
        q.push({fx, fy, i, yu});
      }
    }
  }
  puts("NO");
}
int main() {
  read(n);
  read(m);
  for (register int i = (1); i <= (n); ++i) {
    scanf("%s", s[i] + 1);
    for (register int j = (1); j <= (m); ++j) {
      if (s[i][j] == 'S') sx = i, sy = j;
    }
  }
  bfs();
}
