#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, y, di, cnt;
  node(int _x = 0, int _y = 0, int _di = 0, int _cnt = 0) {
    x = _x;
    y = _y;
    di = _di;
    cnt = _cnt;
  }
};
int n, m;
int cx[5] = {0, 0, 1, -1};
int cy[5] = {1, -1, 0, 0};
char s[1005][1005];
bool mem[1005][1005][5][5];
queue<node> q;
bool check(int x, int y) {
  if (x < 0 || y < 0 || x >= n || y >= m || s[x][y] == '*') return 0;
  return 1;
}
int main() {
  int i, j, sx, sy;
  node t;
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++) scanf(" %s", s[i]);
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (s[i][j] == 'S') {
        sx = i;
        sy = j;
      }
    }
  }
  for (i = 0; i < 4; i++) {
    mem[sx][sy][i][2] = 1;
    q.push(node(sx, sy, i, 2));
  }
  while (!q.empty()) {
    t = q.front();
    q.pop();
    if (s[t.x][t.y] == 'T') {
      printf("YES");
      return 0;
    }
    for (i = 0; i < 4; i++) {
      if (!check(t.x + cx[i], t.y + cy[i])) continue;
      if (i != t.di && t.cnt > 0) {
        if (!mem[t.x + cx[i]][t.y + cy[i]][i][t.cnt - 1]) {
          mem[t.x + cx[i]][t.y + cy[i]][i][t.cnt - 1] = 1;
          q.push(node(t.x + cx[i], t.y + cy[i], i, t.cnt - 1));
        }
      }
      if (i == t.di) {
        if (!mem[t.x + cx[i]][t.y + cy[i]][t.di][t.cnt]) {
          mem[t.x + cx[i]][t.y + cy[i]][t.di][t.cnt] = 1;
          q.push(node(t.x + cx[i], t.y + cy[i], t.di, t.cnt));
        }
      }
    }
  }
  printf("NO");
}
