#include <bits/stdc++.h>
using namespace std;
char mm[1005][1005];
int turn[1005][1005];
int dir[4][2] = {-1, 0, 1, 0, 0, -1, 0, 1};
int n, m, flag = 0;
void dfs(int x, int y, int cnt, int d) {
  int tx = 0, ty = 0;
  if (flag || x < 0 || x > n - 1 || y < 0 || y > m - 1 || cnt > 2) return;
  if (mm[x][y] == 'T') {
    flag = 1;
    return;
  }
  if (mm[x][y] == '*') return;
  if (turn[x][y] == cnt) return;
  turn[x][y] = cnt;
  for (int i = 0; i <= 3; i++) {
    tx = x + dir[i][0];
    ty = y + dir[i][1];
    if (d == i)
      dfs(tx, ty, cnt, i);
    else
      dfs(tx, ty, cnt + 1, i);
  }
}
int main() {
  int ax, ay;
  cin >> n >> m;
  for (int i = 0; i < n; i++) scanf("%s", mm[i]);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (mm[i][j] == 'S') {
        ax = i;
        ay = j;
        break;
      }
    }
  }
  for (int i = 0; i <= 3; i++) {
    memset(turn, -1, sizeof(turn));
    dfs(ax + dir[i][0], ay + dir[i][1], 0, i);
    if (flag) break;
  }
  if (flag)
    puts("YES");
  else
    puts("NO");
  return 0;
}
