#include <bits/stdc++.h>
using namespace std;
char mx[1002][1002];
int dis[1002][1002];
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int n, m;
struct data {
  int x, y, dir;
  int dist;
  data(int X, int Y, int D, int D2) : x(X), y(Y), dir(D), dist(D2) {}
  bool operator>(data other) const {
    if (dist > other.dist)
      return true;
    else if (dist == other.dist && x > other.x)
      return true;
    else if (dist == other.dist && x == other.x && y > other.y)
      return true;
    else if (dist == other.dist && x == other.x && y == other.y &&
             dir > other.dir)
      return true;
    else
      return false;
  }
  bool operator<(data other) const {
    if (dist < other.dist)
      return true;
    else if (dist == other.dist && x < other.x)
      return true;
    else if (dist == other.dist && x == other.x && y < other.y)
      return true;
    else if (dist == other.dist && x == other.x && y == other.y &&
             dir < other.dir)
      return true;
    else
      return false;
  }
};
bool ok(int r, int s) {
  if (r < 0 || s < 0 || r >= n || s >= m) return false;
  return true;
}
void bfs(int sx, int sy) {
  memset(dis, 127, sizeof(dis));
  priority_queue<data, vector<data>, greater<data> > pq;
  dis[sx][sy] = 0;
  pq.push(data(sx, sy, -1, 0));
  while (!pq.empty()) {
    data u = pq.top();
    pq.pop();
    int ux = u.x, uy = u.y, dist = u.dist, dir = u.dir;
    if (dist > dis[ux][uy]) continue;
    for (long long(i) = (0); (i) < (4); (i)++) {
      int r = ux + dx[i], s = uy + dy[i];
      int w = ((dir != -1 && dir != i) ? 1 : 0);
      if (!ok(r, s)) continue;
      if (mx[r][s] == '*') continue;
      if (w + dis[ux][uy] < dis[r][s]) {
        dis[r][s] = w + dis[ux][uy];
        pq.push(data(r, s, i, dis[r][s]));
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  int x, y, xx, yy;
  cin >> n >> m;
  for (long long(i) = (0); (i) < (n); (i)++) {
    for (long long(j) = (0); (j) < (m); (j)++) {
      cin >> mx[i][j];
      if (mx[i][j] == 'S') {
        x = i;
        y = j;
      }
      if (mx[i][j] == 'T') {
        xx = i;
        yy = j;
      }
    }
  }
  bfs(x, y);
  if (dis[xx][yy] <= 2)
    puts("YES");
  else
    puts("NO");
  return 0;
}
