#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const int M = 1e3 + 5;
int n, m;
char a[M][M];
bool us[M][M][4][3];
int nx[4] = {-1, 0, 1, 0};
int ny[4] = {0, 1, 0, -1};
bool ch(int x, int y) {
  return (0 <= x && x < n && 0 <= y && y < m && a[x][y] != '*');
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) scanf(" %c", &a[i][j]);
  int sx, sy, tx, ty;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j)
      if (a[i][j] == 'S')
        sx = i, sy = j;
      else if (a[i][j] == 'T')
        tx = i, ty = j;
  deque<pair<pair<int, int>, pair<int, int> > > q;
  for (int i = 0; i < 4; ++i) {
    us[sx][sy][i][0] = 1;
    q.push_front({{sx, sy}, {i, 0}});
  }
  while (q.size()) {
    pair<pair<int, int>, pair<int, int> > a = q.front();
    q.pop_front();
    pair<int, int> v = a.first;
    pair<int, int> u = a.second;
    for (int i = 0; i < 4; ++i)
      if (ch(v.first + nx[i], v.second + ny[i])) {
        int k = 0;
        if (u.first != i) k = 1;
        if (u.second + k <= 2 &&
            !us[v.first + nx[i]][v.second + ny[i]][i][u.second + k]) {
          us[v.first + nx[i]][v.second + ny[i]][i][u.second + k] = 1;
          if (!k)
            q.push_front(
                {{v.first + nx[i], v.second + ny[i]}, {i, u.second + k}});
          else
            q.push_back(
                {{v.first + nx[i], v.second + ny[i]}, {i, u.second + k}});
        }
      }
  }
  for (int i = 0; i < 4; ++i)
    if (us[tx][ty][i][0] || us[tx][ty][i][1] || us[tx][ty][i][2])
      cout << "YES", exit(0);
  cout << "NO";
}
