#include <bits/stdc++.h>
using namespace std;
string S;
int grid[1000][1000];
pair<int, int> s, e;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int vis[1000][1000][4];
int n, m;
bool get(int x, int y, int i) {
  return (x >= 0 && y >= 0 && x < n && y < m && grid[x][y]);
}
bool bfs() {
  priority_queue<pair<pair<int, int>, pair<int, int> > > q;
  q.push({{4, 4}, {s.first, s.second}});
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      for (int k = 0; k < 4; k++) vis[i][j][k] = 0;
    }
  }
  for (int i = 0; i < 4; i++) vis[s.first][s.second][i] = 4;
  while (!q.empty()) {
    int rem = q.top().first.first;
    int d = q.top().first.second;
    int x = q.top().second.first;
    int y = q.top().second.second;
    q.pop();
    if (rem == 0) continue;
    if (e == make_pair(x, y)) return 1;
    for (int i = 0; i < 4; i++) {
      int xx = x + dx[i];
      int yy = y + dy[i];
      if (get(xx, yy, i)) {
        if (vis[xx][yy][i] < rem - (i != d)) {
          q.push({{rem - (i != d), i}, {xx, yy}});
          vis[xx][yy][i] = 1;
        }
      }
    }
  }
  return 0;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> S;
    for (int j = 0; j < m; j++) {
      if (S[j] == '*')
        grid[i][j] = 0;
      else
        grid[i][j] = 1;
      if (S[j] == 'S')
        s = {i, j};
      else if (S[j] == 'T')
        e = {i, j};
    }
  }
  if (bfs())
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
