#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
bool a[2000][2000], use[2000][2000][6][6];
vector<pair<int, int> > go;
void dfs(int x, int y, int way, int cnt) {
  if (cnt == 3) return;
  use[x][y][way][cnt] = 1;
  for (int i = 1; i <= 4; i++)
    if (i == way) {
      if (a[x + go[i - 1].first][y + go[i - 1].second] &&
          !use[x + go[i - 1].first][y + go[i - 1].second][i][cnt])
        dfs(x + go[i - 1].first, y + go[i - 1].second, i, cnt);
    } else if (abs(i - way) != 2) {
      if (a[x + go[i - 1].first][y + go[i - 1].second] &&
          !use[x + go[i - 1].first][y + go[i - 1].second][i][cnt + 1])
        dfs(x + go[i - 1].first, y + go[i - 1].second, i, cnt + 1);
    }
}
signed main() {
  int n = 0, m = 0;
  cin >> n >> m;
  int si = 0, sj = 0, fi = 0, fj = 0;
  for (int i = 1; i <= n; i++) {
    string st = "";
    cin >> st;
    for (int j = 1; j <= m; j++)
      if (st[j - 1] != '*') a[i][j] = 1;
    for (int j = 1; j <= m; j++)
      if (st[j - 1] == 'S') {
        si = i;
        sj = j;
      } else if (st[j - 1] == 'T') {
        fi = i;
        fj = j;
      }
  }
  go.push_back({1, 0});
  go.push_back({0, 1});
  go.push_back({-1, 0});
  go.push_back({0, -1});
  dfs(si, sj, 1, 0);
  dfs(si, sj, 2, 0);
  dfs(si, sj, 3, 0);
  dfs(si, sj, 4, 0);
  for (int way = 1; way <= 4; way++)
    for (int cnt = 0; cnt <= 2; cnt++)
      if (use[fi][fj][way][cnt]) {
        cout << "YES";
        return (0);
      }
  cout << "NO";
}
