#include <bits/stdc++.h>
using namespace std;
using PII = pair<int, tuple<int, int, char>>;
const int N = 5e5, M = 1005;
int n, m;
int A, B, C, D;
char mp[M][M];
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
char dir[4] = {'A', 'A', 'B', 'B'};
int dist[M][M];
int vis[M][M];
priority_queue<PII, vector<PII>, greater<PII>> q;
void bfs();
int main() {
  std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> mp[i][j];
      if (mp[i][j] == 'S') {
        A = i;
        B = j;
      }
      if (mp[i][j] == 'T') {
        C = i;
        D = j;
      }
    }
  }
  bfs();
  if (dist[C][D] <= 2)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
void bfs() {
  memset(dist, 0x3f, sizeof(dist));
  q.push({-1, make_tuple(A, B, 'X')});
  dist[A][B] = -1;
  while (q.size()) {
    auto now = q.top();
    q.pop();
    int x, y;
    char op;
    tie(x, y, op) = now.second;
    int dis = now.first;
    if (dis > 2) continue;
    for (int i = 0; i < 4; i++) {
      int xx = x + dx[i];
      int yy = y + dy[i];
      if (xx > n || xx < 1 || yy < 1 || yy > m || mp[xx][yy] == '*') continue;
      if (dist[xx][yy] > dist[x][y] + (dir[i] != op)) {
        dist[xx][yy] = dis + (dir[i] != op);
        q.push({dist[xx][yy], make_tuple(xx, yy, dir[i])});
      }
    }
  }
}
