#include <bits/stdc++.h>
using namespace std;
int go[4][2] = {0, 1, 1, 0, 0, -1, -1, 0};
int n, m;
char Map[1010][1010];
int vis[1010][1010][4];
int sx, sy, tx, ty;
int flag = 0;
void dfs(int x, int y, int dir, int cnt) {
  if (cnt >= 3) return;
  if (x == tx && y == ty) {
    flag = 1;
    return;
  }
  if (cnt >= vis[x][y][dir]) return;
  if (x > n || x < 1 || y > m || y < 1 || Map[x][y] == '*') return;
  vis[x][y][dir] = cnt;
  for (int i = 0; i < 4; i++) {
    int nx = x + go[i][0], ny = y + go[i][1];
    if (i == dir)
      dfs(nx, ny, i, cnt);
    else
      dfs(nx, ny, i, cnt + 1);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%s", Map[i] + 1);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (Map[i][j] == 'S') {
        sx = i;
        sy = j;
      } else if (Map[i][j] == 'T') {
        tx = i;
        ty = j;
      }
      for (int k = 0; k < 4; k++) vis[i][j][k] = 0x3f3f3f3f;
    }
  }
  for (int i = 0; i < 4; i++) {
    if (!flag) dfs(sx + go[i][0], sy + go[i][1], i, 0);
  }
  if (flag)
    printf("YES");
  else
    printf("NO");
}
