#include <bits/stdc++.h>
using namespace std;
int n, m;
char s[1005][1005];
int dp[4][1005][1005];
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
bool tag = 0;
int sx, sy, ex, ey;
inline void dfs(int x, int y, int dir, int cur) {
  if (tag) return;
  if (x == ex && y == ey) {
    tag = 1;
    return;
  }
  for (int i = 0; i < 4; i++) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if (nx >= 0 && nx < n && ny >= 0 && ny < m && s[nx][ny] != '*') {
      int cnt = 0;
      if (i != dir) cnt = 1;
      if (cur + cnt <= 2 && dp[dir][nx][ny] > (cur + cnt)) {
        dp[dir][nx][ny] = (cur + cnt);
        dfs(nx, ny, i, cur + cnt);
      }
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%s", s[i]);
    for (int j = 0; j < m; j++) {
      if (s[i][j] == 'S') {
        sx = i;
        sy = j;
      }
      if (s[i][j] == 'T') {
        ex = i;
        ey = j;
      }
    }
  }
  for (int i = 0; i < 4; i++) {
    memset(dp, 63, sizeof(dp));
    tag = 0;
    dfs(sx, sy, i, 0);
    if (tag) {
      printf("YES\n");
      return 0;
    }
  }
  printf("NO\n");
  return 0;
}
