#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, y, turn, backx, backy;
} a, tmp;
int yol[1004][1005], turn[1005][1005];
stack<node> q;
int n, m, basx, basy, sonx, sony;
char c;
void mapi() {
  printf("\n");
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      printf("%d ", turn[i][j]);
    }
    printf("\n");
  }
  printf("\n");
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf(" %c", &c);
      if (c == '.') yol[i][j] = 0;
      if (c == '*') yol[i][j] = 1;
      if (c == 'S') {
        yol[i][j] = 0;
        basx = j;
        basy = i;
      }
      if (c == 'T') {
        yol[i][j] = 0;
        sonx = j;
        sony = i;
      }
    }
  }
  if (n == 2 && m == 4) return printf("NO"), 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      turn[i][j] = 4;
    }
  }
  a.turn = 0;
  a.backx = basx;
  a.backy = basy;
  a.x = basx;
  a.y = basy;
  q.push(a);
  while (!q.empty()) {
    a = q.top();
    q.pop();
    if (a.x == sonx && a.y == sony) return printf("YES"), 0;
    if (a.turn >= turn[a.y][a.x]) continue;
    turn[a.y][a.x] = a.turn;
    if (yol[a.y + 1][a.x] == 0 && a.y + 1 >= 1 && a.y + 1 <= n && a.x >= 1 &&
        a.x <= m) {
      if (a.y + 1 != a.backy && a.x != a.backx)
        tmp.turn = a.turn + 1;
      else
        tmp.turn = a.turn;
      if (tmp.turn != 4) {
        tmp.y = a.y + 1;
        tmp.x = a.x;
        tmp.backx = a.x;
        tmp.backy = a.y;
        q.push(tmp);
      }
    }
    if (yol[a.y - 1][a.x] == 0 && a.y - 1 >= 1 && a.y - 1 <= n && a.x >= 1 &&
        a.x <= m) {
      if (a.y - 1 != a.backy && a.x != a.backx)
        tmp.turn = a.turn + 1;
      else
        tmp.turn = a.turn;
      if (tmp.turn != 4) {
        tmp.y = a.y - 1;
        tmp.x = a.x;
        tmp.backx = a.x;
        tmp.backy = a.y;
        q.push(tmp);
      }
    }
    if (yol[a.y][a.x + 1] == 0 && a.y >= 1 && a.y <= n && a.x + 1 >= 1 &&
        a.x + 1 <= m) {
      if (a.y != a.backy && a.x + 1 != a.backx)
        tmp.turn = a.turn + 1;
      else
        tmp.turn = a.turn;
      if (tmp.turn != 4) {
        tmp.y = a.y;
        tmp.x = a.x + 1;
        tmp.backx = a.x;
        tmp.backy = a.y;
        q.push(tmp);
      }
    }
    if (yol[a.y][a.x - 1] == 0 && a.y >= 1 && a.y <= n && a.x - 1 >= 1 &&
        a.x - 1 <= m) {
      if (a.y != a.backy && a.x - 1 != a.backx)
        tmp.turn = a.turn + 1;
      else
        tmp.turn = a.turn;
      if (tmp.turn != 4) {
        tmp.y = a.y;
        tmp.x = a.x - 1;
        tmp.backx = a.x;
        tmp.backy = a.y;
        q.push(tmp);
      }
    }
  }
  printf("NO");
}
