#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
inline int safe_mul(const int x, const int y)
    __attribute__((warn_unused_result));
int const maxn = 1005;
char s[maxn][maxn];
int used[maxn][maxn];
int main() {
  cout << fixed << setprecision(20);
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  for (int i = 0; i < maxn; ++i)
    for (int j = 0; j + 1 < maxn; ++j) s[i][j] = '*';
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) cin >> &(s[i][1]);
  array<int, 4> dx = {0, 0, -1, 1};
  array<int, 4> dy = {-1, 1, 0, 0};
  queue<pair<int, int>> qu;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      if (s[i][j] == 'S') {
        qu.push({i, j});
        used[i][j] = 1;
      }
  while (!qu.empty()) {
    int x, y;
    tie(x, y) = qu.front();
    qu.pop();
    for (int k = 0; k < 4; ++k) {
      int cx = x;
      int cy = y;
      for (; s[cx][cy] != '*' && s[cx][cy]; cx += dx[k], cy += dy[k]) {
        if (!used[cx][cy]) {
          used[cx][cy] = used[x][y] + 1;
          qu.push({cx, cy});
        }
      }
    }
  }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      if (s[i][j] == 'T') {
        {
          cout << (used[i][j] > 0 && used[i][j] <= 4 ? "YES" : "NO") << '\n';
          exit(0);
        };
      }
}
