#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int N = 1000005;
const double PI = 4 * atan(1);
long long m, x, y, n, p, z, k;
long long xs, ys, xf, yf;
long long dist[1005][1005][5];
bool vis[1005][1005];
char grid[1005][1005];
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
bool ingrid(long long x, long long y) {
  return x >= 0 && y >= 0 && x < n && y < m && grid[x][y] != '*';
}
bool bfs() {
  priority_queue<pair<pair<long long, long long>, pair<long long, long long> > >
      q;
  for (int i = 0; i < 4; i++) {
    dist[xs][ys][i] = 0;
    q.push(make_pair(make_pair(0, i), make_pair(xs, ys)));
  }
  while (!q.empty()) {
    long long x, y, dir, dis;
    x = q.top().second.first;
    y = q.top().second.second;
    dir = q.top().first.second;
    dis = -q.top().first.first;
    q.pop();
    if (x == xf && y == yf) {
      if (dist[x][y][dir] <= 2) return true;
      continue;
    }
    if (dist[x][y][dir] < dis) continue;
    for (int i = 0; i < 4; i++) {
      if (ingrid(x + dx[i], y + dy[i])) {
        if ((i != dir) + dis <= 2 &&
            dist[x + dx[i]][y + dy[i]][i] > ((i != dir) + dis)) {
          dist[x + dx[i]][y + dy[i]][i] = ((i != dir) + dis);
          q.push(make_pair(make_pair(-((i != dir) + dis), i),
                           make_pair(x + dx[i], y + dy[i])));
        }
      }
    }
  }
  return false;
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      for (int k = 0; k < 4; k++) {
        dist[i][j][k] = 1e18;
      }
      cin >> grid[i][j];
      if (grid[i][j] == 'S') {
        xs = i;
        ys = j;
      } else if (grid[i][j] == 'T') {
        xf = i;
        yf = j;
      }
    }
  }
  cout << (bfs() ? "YES" : "NO");
  return 0;
}
