#include <bits/stdc++.h>
using namespace std;
int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, -1, 1};
int sx, sy;
char m[1005][1005];
int vis[1005][1005][4];
int flag;
int n, k;
void bfs(int x, int y, int l, int c) {
  if (x < 0 || x >= n || y < 0 || y >= k) return;
  if (m[x][y] == '*') return;
  if (vis[x][y][l] <= c) return;
  if (c > 2) return;
  vis[x][y][l] = c;
  if (m[x][y] == 'T') {
    flag = 1;
    return;
  }
  for (int i = 0; i < 4; i++) {
    int xx = x + dx[i];
    int yy = y + dy[i];
    if (l == i)
      bfs(xx, yy, l, c);
    else
      bfs(xx, yy, i, c + 1);
  }
  return;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%s", m[i]);
    for (int j = 0; j < k; j++) {
      if (m[i][j] == 'S') {
        sx = i;
        sy = j;
      }
    }
  }
  flag = 0;
  memset(vis, 0x3f3f3f, sizeof(vis));
  for (int i = 0; i < 4; i++) {
    int xx, yy;
    xx = sx + dx[i];
    yy = sy + dy[i];
    bfs(xx, yy, i, 0);
  }
  if (flag)
    printf("YES\n");
  else
    printf("NO\n");
}
