#include <bits/stdc++.h>
using namespace std;
const int MAX = 1010;
int n, m, xi, yi;
char city[MAX][MAX];
int dirX[4] = {-1, +1, 0, 0};
int dirY[4] = {0, 0, -1, +1};
bool visit[MAX][MAX][3][4];
void solve(int x, int y, int moves, int dir) {
  if (moves > 2) return;
  if (x < 0 || x >= n || y < 0 || y >= m) return;
  if (city[x][y] == '*') return;
  if (visit[x][y][moves][dir]) return;
  visit[x][y][moves][dir] = true;
  if (city[x][y] == 'T') {
    cout << "YES\n";
    exit(0);
  }
  for (int i = 0; i < 4; i++)
    solve(x + dirX[i], y + dirY[i], moves + (i != dir), i);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> city[i];
    for (int j = 0; j < m; j++)
      if (city[i][j] == 'S') xi = i, yi = j;
  }
  for (int i = 0; i < 4; i++) solve(xi, yi, 0, i);
  cout << "NO\n";
  return 0;
}
