#include <bits/stdc++.h>
using namespace std;
int f[1010][1010][4];
int sx, sy, tx, ty;
int dx[4] = {0, 0, -1, 1};
int dy[4] = {1, -1, 0, 0};
deque<int> q;
bool vis[1010][1010][4];
char g[1010][1010];
int n, m;
int main() {
  for (int i = 0; i <= 1000; i++)
    for (int j = 0; j <= 1000; j++)
      for (int k = 0; k < 4; k++) f[i][j][k] = 1 << 30;
  cin >> n >> m;
  getchar();
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      g[i][j] = getchar();
      if (g[i][j] == 'S') sx = i, sy = j;
      if (g[i][j] == 'T') tx = i, ty = j;
    }
    getchar();
  }
  for (int i = 0; i < 4; i++) {
    f[sx][sy][i] = 0;
    q.push_back((sx * m + sy) * 4 + i);
  }
  memset(vis, 0, sizeof(vis));
  while (!q.empty()) {
    int x = q.front();
    q.pop_front();
    int d = x % 4;
    x /= 4;
    int y = x % m;
    x /= m;
    if (vis[x][y][d]) continue;
    vis[x][y][d] = 1;
    int nx = x + dx[d];
    int ny = y + dy[d];
    if (nx >= 0 && nx < n && ny >= 0 && ny < m) {
      if (g[nx][ny] != '*' && !vis[nx][ny][d])
        f[nx][ny][d] = min(f[nx][ny][d], f[x][y][d]),
        q.push_front((nx * m + ny) * 4 + d);
    }
    for (int i = 0; i < 4; i++)
      if (!vis[x][y][i]) {
        f[x][y][i] = min(f[x][y][i], f[x][y][d] + 1);
        q.push_back((x * m + y) * 4 + i);
      }
  }
  int ans = 1 << 30;
  for (int i = 0; i < 4; i++)
    if (f[tx][ty][i] != -1) ans = min(ans, f[tx][ty][i]);
  if (ans > 2)
    puts("NO");
  else
    puts("YES");
  return 0;
}
