#include <bits/stdc++.h>
using namespace std;
char G[1010][1010];
int V[1010][1010];
int n, m;
int main(int argc, char const *argv[]) {
  cin >> n >> m;
  int si, sj;
  int ti, tj;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> G[i][j];
      if (G[i][j] == 'S') {
        si = i;
        sj = j;
      } else if (G[i][j] == 'T') {
        ti = i;
        tj = j;
      }
    }
  }
  V[si][sj] = 1;
  queue<pair<int, int>> q;
  queue<pair<int, int>> q2;
  int dx[] = {1, 0, -1, 0};
  int dy[] = {0, 1, 0, -1};
  for (int k = 0; k < 4; k++) {
    int ci = si;
    int cj = sj;
    while (true) {
      ci += dx[k];
      cj += dy[k];
      if (ci >= 0 && cj >= 0 && ci < n && cj < m && G[ci][cj] != '*') {
        V[ci][cj] = 1;
        q.push({ci, cj});
      } else {
        break;
      }
    }
  }
  while (q.size()) {
    auto pt = q.front();
    q.pop();
    for (int k = 0; k < 4; k++) {
      int ci = pt.first;
      int cj = pt.second;
      while (true) {
        ci += dx[k];
        cj += dy[k];
        if (ci >= 0 && cj >= 0 && ci < n && cj < m && G[ci][cj] != '*') {
          V[ci][cj] = 1;
          q2.push({ci, cj});
        } else {
          break;
        }
      }
    }
  }
  bool isReachable = false;
  for (int k = 0; k < 4; k++) {
    int ci = ti;
    int cj = tj;
    while (true) {
      ci += dx[k];
      cj += dy[k];
      if (ci >= 0 && cj >= 0 && ci < n && cj < m && G[ci][cj] != '*') {
        if (V[ci][cj] == 1) {
          isReachable = true;
        }
      } else {
        break;
      }
    }
  }
  if (isReachable) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
