#include <bits/stdc++.h>
using namespace std;
const int N = 1000 + 10;
int n, m, sx, sy, tx, ty;
char s[N][N];
int dr[] = {0, 0, 1, -1};
int dc[] = {1, -1, 0, 0};
int cost[N][N];
bool vis[N][N];
struct node {
  int x, y, t, d;
  node(int X = 0, int Y = 0, int T = 0, int D = 0) {
    x = X, y = Y, t = T, d = D;
  }
  bool operator<(const node &o) const { return t > o.t; }
};
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%s", s[i]);
    for (int j = 0; j < m; ++j) {
      if (s[i][j] == 'S')
        sx = i, sy = j;
      else if (s[i][j] == 'T')
        tx = i, ty = j;
      cost[i][j] = 1e9;
    }
  }
  priority_queue<node> q;
  q.push(node(sx, sy, -1, -1));
  cost[sx][sy] = -1;
  int x, y, t, nx, ny, nt, d, nd;
  while (!q.empty()) {
    x = q.top().x;
    y = q.top().y;
    t = q.top().t;
    d = q.top().d;
    q.pop();
    if (vis[x][y]) continue;
    vis[x][y] = true;
    for (int k = 0; k < 4; ++k) {
      nx = x + dr[k], ny = y + dc[k];
      if (nx < 0 || nx >= n || ny < 0 || ny >= m || vis[nx][ny] ||
          s[nx][ny] == '*')
        continue;
      nd = k;
      nt = cost[x][y] + (d != nd);
      if (cost[nx][ny] < nt) continue;
      cost[nx][ny] = nt;
      q.push(node(nx, ny, nt, nd));
    }
  }
  puts(cost[tx][ty] <= 2 ? "YES" : "NO");
  return 0;
}
