#include <bits/stdc++.h>
using namespace std;
int n, flag = 0, m;
int sy, sx;
char Map[1010][1010];
int vis[1010][1010][5];
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
void Dfs(int x, int y, int c, int j);
void Dfs(int x, int y, int c, int j) {
  int xx, yy;
  if (x >= n || y >= m || x < 0 || y < 0) return;
  if (Map[x][y] == '*') return;
  if (vis[x][y][j] <= c) return;
  if (c > 2) return;
  vis[x][y][j] = c;
  if (Map[x][y] == 'T') {
    flag = 1;
    return;
  }
  for (int i = 0; i < 4; i++) {
    xx = x + dx[i];
    yy = y + dy[i];
    if (i == j)
      Dfs(xx, yy, c, i);
    else
      Dfs(xx, yy, c + 1, i);
  }
  return;
}
int main() {
  int xx, yy;
  cin >> n >> m;
  memset(vis, 0x1f1f1f, sizeof(vis));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> Map[i][j];
      if (Map[i][j] == 'S') {
        sx = i;
        sy = j;
      }
    }
  }
  for (int i = 0; i < 4; i++) {
    xx = sx + dx[i];
    yy = sy + dy[i];
    Dfs(xx, yy, 0, i);
  }
  if (flag)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
