#include <bits/stdc++.h>
bool d[1005][1005] = {};
bool vis[1005][1005][4][4] = {};
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  std::cout.tie(NULL);
  std::string s;
  std::queue<std::pair<std::pair<int, int>, std::pair<int, int> > > bfs;
  int n, m, si, sj, ti, tj;
  std::cin >> n >> m;
  for (int i = 0; i < n; i++) {
    std::cin >> s;
    for (int j = 0; j < m; j++) {
      if (s.at(j) == '*')
        d[i][j] = false;
      else
        d[i][j] = true;
      if (s.at(j) == 'S') {
        si = i;
        sj = j;
      }
      if (s.at(j) == 'T') {
        ti = i;
        tj = j;
      }
    }
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      for (int k = 0; k < 4; k++)
        for (int l = 0; l < 4; l++) vis[i][j][k][l] = false;
  bfs.push(std::make_pair(std::make_pair(si, sj), std::make_pair(0, 0)));
  bfs.push(std::make_pair(std::make_pair(si, sj), std::make_pair(1, 0)));
  bfs.push(std::make_pair(std::make_pair(si, sj), std::make_pair(2, 0)));
  bfs.push(std::make_pair(std::make_pair(si, sj), std::make_pair(3, 0)));
  while (!bfs.empty()) {
    int i = bfs.front().first.first;
    int j = bfs.front().first.second;
    int dir = bfs.front().second.first;
    int tr = bfs.front().second.second;
    if (i >= 0 && i < n && j >= 0 && j < m && tr < 3 && d[i][j] &&
        !vis[i][j][dir][tr]) {
      vis[i][j][dir][tr] = true;
      bfs.push(std::make_pair(std::make_pair(i - 1, j),
                              std::make_pair(0, tr + (dir != 0))));
      bfs.push(std::make_pair(std::make_pair(i + 1, j),
                              std::make_pair(1, tr + (dir != 1))));
      bfs.push(std::make_pair(std::make_pair(i, j - 1),
                              std::make_pair(2, tr + (dir != 2))));
      bfs.push(std::make_pair(std::make_pair(i, j + 1),
                              std::make_pair(3, tr + (dir != 3))));
    }
    bfs.pop();
  }
  std::cout << ((vis[ti][tj][0][0] || vis[ti][tj][1][0] || vis[ti][tj][2][0] ||
                 vis[ti][tj][3][0] || vis[ti][tj][0][1] || vis[ti][tj][1][1] ||
                 vis[ti][tj][2][1] || vis[ti][tj][3][1] || vis[ti][tj][0][2] ||
                 vis[ti][tj][1][2] || vis[ti][tj][2][2] || vis[ti][tj][3][2])
                    ? "YES"
                    : "NO")
            << '\n';
}
