#include <bits/stdc++.h>
using namespace std;
int n, m, d[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
char mp[1005][1005];
bool vis[1001][1001][4][3];
struct node {
  int x, y, di, r;
  node(int a = -1, int b = -1, int c = -1, int d = -1) {
    x = a;
    y = b;
    di = c;
    r = d;
  }
};
bool solve(int sx, int sy, int ex, int ey) {
  if (sx == -1 || sy == -1 || ex == -1 || ey == -1) return false;
  memset(vis, 0, sizeof(vis));
  queue<node> q;
  while (!q.empty()) q.pop();
  for (int i = 0; i < 4; ++i) {
    vis[sx][sy][i][2] = 1;
    q.push(node(sx, sy, i, 2));
  }
  while (!q.empty()) {
    node u = q.front();
    q.pop();
    for (int i = 0; i < 4; ++i) {
      node v;
      if (i != u.di)
        v = node(u.x + d[i][0], u.y + d[i][1], i, u.r - 1);
      else
        v = node(u.x + d[i][0], u.y + d[i][1], i, u.r);
      if (v.r < 0 || v.x < 0 || v.x >= n || v.y < 0 || v.y >= m) continue;
      if (mp[v.x][v.y] == '*') continue;
      if (vis[v.x][v.y][v.di][v.r]) continue;
      vis[v.x][v.y][v.di][v.r] = 1;
      q.push(v);
    }
  }
  for (int i = 0; i < 4; ++i)
    for (int j = 0; j < 2; ++j)
      if (vis[ex][ey][i][j]) return true;
  return false;
}
int main() {
  scanf("%d%d", &n, &m);
  int sx = -1, sy = -1, ex = -1, ey = -1;
  for (int i = 0; i < n; ++i) {
    scanf("%s", mp[i]);
    for (int j = 0; j < m; ++j) {
      if (mp[i][j] == 'S') {
        sx = i;
        sy = j;
      }
      if (mp[i][j] == 'T') {
        ex = i;
        ey = j;
      }
    }
  }
  if (solve(sx, sy, ex, ey))
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
