#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<vector<char> > a;
vector<vector<vector<int> > > d;
struct vertex {
  int x, y, v;
  vertex(int a = 0, int b = 0, int c = 0) : x(a), y(b), v(c) {}
};
vertex s, t;
const int inf = 1e9;
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
vector<vector<vector<int> > > used;
void bfs01() {
  queue<vertex> q0, q1;
  for (int i = 0; i < 4; i++) {
    s.v = i;
    d[s.x][s.y][s.v] = 0;
    q0.push(s);
  }
  while (!q0.empty() || !q1.empty()) {
    if (q0.empty()) {
      q0 = q1;
      while (!q1.empty()) q1.pop();
    }
    vertex cur = q0.front();
    q0.pop();
    if (used[cur.x][cur.y][cur.v]) continue;
    used[cur.x][cur.y][cur.v] = 1;
    for (int i = 0; i < 4; i++) {
      vertex newv = vertex(cur.x + dx[i], cur.y + dy[i], i);
      if ((newv.x < 0) || (newv.y < 0) || (newv.x >= n) || (newv.y >= m) ||
          used[newv.x][newv.y][newv.v] || (a[newv.x][newv.y] == '*'))
        continue;
      if (cur.v == newv.v) {
        d[newv.x][newv.y][newv.v] =
            min(d[cur.x][cur.y][cur.v], d[newv.x][newv.y][newv.v]);
        q0.push(newv);
      } else {
        d[newv.x][newv.y][newv.v] =
            min(d[cur.x][cur.y][cur.v] + 1, d[newv.x][newv.y][newv.v]);
        q1.push(newv);
      }
    }
  }
}
int main() {
  scanf("%d %d\n", &n, &m);
  a.resize(n, vector<char>(m + 1));
  used.resize(n, vector<vector<int> >(m, vector<int>(4)));
  d.resize(n, vector<vector<int> >(m, vector<int>(4, inf)));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m + 1; j++) {
      scanf("%c", &a[i][j]);
      if (a[i][j] == 'S') s = vertex(i, j);
      if (a[i][j] == 'T') t = vertex(i, j);
    }
  }
  bfs01();
  if ((d[t.x][t.y][0] <= 2) || (d[t.x][t.y][1] <= 2) || (d[t.x][t.y][2] <= 2) ||
      (d[t.x][t.y][3] <= 2))
    printf("YES");
  else
    printf("NO");
}
