#include <bits/stdc++.h>
using namespace std;
const int N = 3 * 100 * 1000 + 16;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int n, m;
int sx, sy, tx, ty;
string g[1111];
int bst[1111][1111];
bool can[1111][1111][4];
inline bool valid(int x, int y) {
  return (x >= 0 && x < n && y >= 0 && y < m) &&
         (g[x][y] == 'T' || g[x][y] == '.');
}
int main(int argc, char const *argv[]) {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    cin >> g[i];
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (g[i][j] == 'S') {
        sx = i;
        sy = j;
      } else if (g[i][j] == 'T') {
        tx = i;
        ty = j;
      }
    }
  }
  memset(bst, 0x3f, sizeof bst);
  bst[sx][sy] = 0;
  for (int i = 0; i < 4; ++i) can[sx][sy][i] = true;
  queue<pair<int, int> > Q;
  Q.push(make_pair(sx, sy));
  while (Q.size()) {
    auto p = Q.front();
    Q.pop();
    int x = p.first;
    int y = p.second;
    if (bst[x][y] > 2) continue;
    if (bst[tx][ty] <= 2) {
      cout << "YES" << endl;
      exit(0);
    }
    for (int i = 0; i < 4; ++i) {
      int xx = x + dx[i];
      int yy = y + dy[i];
      if (valid(xx, yy)) {
        int moves = bst[x][y] + !can[x][y][i];
        if (moves < bst[xx][yy]) {
          memset(can[xx][yy], 0, sizeof(can[xx][yy]));
          can[xx][yy][i] = true;
          bst[xx][yy] = moves;
          Q.push(make_pair(xx, yy));
        } else if (moves == bst[xx][yy]) {
          can[xx][yy][i] = true;
        }
      }
    }
  }
  cout << (bst[tx][ty] > 2 ? "NO" : "YES") << endl;
  return 0;
}
