#include <bits/stdc++.h>
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const int N = 1e3 + 5;
int n, m, h[N][N][5], vis[N][N], x, y, X, Y, z1, z2;
string s[N];
void dijsktra(int x, int y) {
  priority_queue<pair<pair<int, int>, pair<int, int>>,
                 vector<pair<pair<int, int>, pair<int, int>>>,
                 greater<pair<pair<int, int>, pair<int, int>>>>
      pq;
  pq.push({{0, 0}, {x, y}}),
      h[x][y][1] = h[x][y][2] = h[x][y][3] = h[x][y][4] = 0;
  while (pq.size()) {
    pair<pair<int, int>, pair<int, int>> p = pq.top();
    pq.pop();
    x = p.second.first, y = p.second.second;
    z1 = p.first.first, z2 = p.first.second;
    if (z1 > 2) break;
    if (!z1 and !z2) {
      if (x + 1 <= n and s[x + 1][y] != '*')
        h[x + 1][y][1] = 0, pq.push({{0, 1}, {x + 1, y}});
      if (x - 1 >= 1 and s[x - 1][y] != '*')
        h[x - 1][y][3] = 0, pq.push({{0, 3}, {x - 1, y}});
      if (y + 1 <= m and s[x][y + 1] != '*')
        h[x][y + 1][2] = 0, pq.push({{0, 2}, {x, y + 1}});
      if (y - 1 >= 1 and s[x][y - 1] != '*')
        h[x][y - 1][4] = 0, pq.push({{0, 4}, {x, y - 1}});
      continue;
    }
    if (x + 1 <= n and s[x + 1][y] != '*') {
      if (z2 == 1) {
        if (z1 < h[x + 1][y][1])
          h[x + 1][y][1] = z1, pq.push({{z1, 1}, {x + 1, y}});
      } else {
        if (z1 + 1 < h[x + 1][y][1])
          h[x + 1][y][1] = z1 + 1, pq.push({{z1 + 1, 1}, {x + 1, y}});
      }
    }
    if (x - 1 >= 1 and s[x - 1][y] != '*') {
      if (z2 == 3) {
        if (z1 < h[x - 1][y][3])
          h[x - 1][y][3] = z1, pq.push({{z1, 3}, {x - 1, y}});
      } else {
        if (z1 + 1 < h[x - 1][y][3])
          h[x - 1][y][3] = z1 + 1, pq.push({{z1 + 1, 3}, {x - 1, y}});
      }
    }
    if (y + 1 <= m and s[x][y + 1] != '*') {
      if (z2 == 2) {
        if (z1 < h[x][y + 1][2])
          h[x][y + 1][2] = z1, pq.push({{z1, 2}, {x, y + 1}});
      } else {
        if (z1 + 1 < h[x][y + 1][2])
          h[x][y + 1][2] = z1 + 1, pq.push({{z1 + 1, 2}, {x, y + 1}});
      }
    }
    if (y - 1 >= 1 and s[x][y - 1] != '*') {
      if (z2 == 4) {
        if (z1 < h[x][y - 1][4])
          h[x][y - 1][4] = z1, pq.push({{z1, 4}, {x, y - 1}});
      } else {
        if (z1 + 1 < h[x][y - 1][4])
          h[x][y - 1][4] = z1 + 1, pq.push({{z1 + 1, 4}, {x, y - 1}});
      }
    }
  }
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m;
  int x1, y1, x2, y2;
  for (int i = 1; i <= n; i++) cin >> s[i], s[i] = "$" + s[i];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      h[i][j][1] = h[i][j][2] = h[i][j][3] = h[i][j][4] = INT_MAX;
      if (s[i][j] == 'S') x1 = i, y1 = j, X = i, Y = j;
      if (s[i][j] == 'T') x2 = i, y2 = j;
    }
  dijsktra(X, Y);
  if (h[x2][y2][1] <= 2 or h[x2][y2][2] <= 2 or h[x2][y2][3] <= 2 or
      h[x2][y2][4] <= 2)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
