#include <bits/stdc++.h>
using namespace std;
long long n, m;
char g[1005][1005];
long long sr, sc, tr, tc;
bool seen[5][5][1005][1005];
long long dirR[4] = {0, 0, 1, -1};
long long dirC[4] = {1, -1, 0, 0};
bool found;
void dfs(long long row, long long col, long long dir, long long numTurns) {
  if (numTurns > 3) return;
  seen[numTurns][dir][row][col] = true;
  if (row == tr && col == tc) {
    found = true;
    return;
  }
  for (long long i = 0; i < 4; i++) {
    long long nr = row + dirR[i], nc = col + dirC[i];
    if (nr >= 0 && nr < n && nc >= 0 && nc < m) {
      if (g[nr][nc] == '*') continue;
      long long newTurns = numTurns + (i != dir);
      if (!seen[newTurns][i][nr][nc]) dfs(nr, nc, i, newTurns);
    }
  }
}
void solve() {
  cin >> n >> m;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      cin >> g[i][j];
      if (g[i][j] == 'S') {
        sr = i, sc = j;
      }
      if (g[i][j] == 'T') {
        tr = i, tc = j;
      }
    }
  }
  found = false;
  dfs(sr, sc, 4, 0);
  if (found) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
}
