#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int INF = 0x3f3f3f3f;
const int N = 1e3 + 5;
string s[N];
int n, m, best[N][N];
int dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
inline bool valid(int x, int y) {
  return (x >= 0 and x < n and y >= 0 and y < m and s[x][y] != '*');
}
void dfs(int x, int y, int d = -1) {
  if (best[x][y] > 2) return;
  if (s[x][y] == 'T') {
    cout << "YES" << '\n';
    exit(0);
  }
  for (int i = 0; i < 4; i++) {
    int nx = x + dx[i], ny = y + dy[i], add = 1;
    if (d == -1 or d == i) add = 0;
    int nbest = best[x][y] + add;
    if (valid(nx, ny) and (best[nx][ny] == -1 or best[nx][ny] > nbest)) {
      best[nx][ny] = nbest;
      dfs(nx, ny, i);
    }
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  memset(best, -1, sizeof best);
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (s[i][j] == 'S') {
        best[i][j] = 0;
        dfs(i, j);
      }
    }
  }
  cout << "NO" << '\n';
  return 0;
}
