#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
int n, m, bx, by, endx, endy;
char grid[N][N];
int vis[N][N][5][5];
int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, -1, 0, 1};
void solve(int x, int y, int direcao, int cnt) {
  if (cnt == 3) return;
  if (x == endx and y == endy) {
    printf("YES\n");
    exit(0);
  }
  if (x < 0 or x >= n or y < 0 or y >= m or vis[x][y][direcao][cnt] or
      grid[x][y] == '*')
    return;
  vis[x][y][direcao][cnt] = 1;
  solve(x + dx[direcao], y + dy[direcao], direcao, cnt);
  for (int k = 0; k < 4; k++) {
    if (k == direcao) continue;
    solve(x, y, k, cnt + 1);
  }
}
int main(void) {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf(" %s", grid[i]);
    for (int j = 0; j < m; j++) {
      if (grid[i][j] == 'S') {
        bx = i;
        by = j;
        grid[i][j] = '.';
      } else if (grid[i][j] == 'T') {
        endx = i;
        endy = j;
        grid[i][j] = '.';
      }
    }
  }
  for (int k = 0; k < 4; k++) solve(bx, by, k, 0);
  printf("NO\n");
  return 0;
}
