#include <bits/stdc++.h>
using namespace std;
const long long int N = 1005;
long long int n, m;
string s[N];
pair<long long int, long long int> source, dest;
long long int vis[N][N][5][5];
long long int dx[] = {1, 0, -1, 0};
long long int dy[] = {0, 1, 0, -1};
bool valid(long long int x, long long int y, long long int cnt,
           long long int d) {
  if (x < 0 || x > n - 1 || y < 0 || y > m - 1) return false;
  if (vis[x][y][cnt][d]) return false;
  if (s[x][y] == '*') return false;
  return true;
}
void bfs(long long int x, long long int y, long long int cnt, long long int d) {
  queue<tuple<long long int, long long int, long long int, long long int> > q;
  q.push(tie(x, y, cnt, d));
  while (!q.empty()) {
    long long int x, y, cnt, d;
    tie(x, y, cnt, d) = q.front();
    q.pop();
    if (cnt > 2) continue;
    vis[x][y][cnt][d] = 1;
    for (long long int i = 1; i < 5; i++) {
      long long int nx = x + dx[i - 1];
      long long int ny = y + dy[i - 1];
      if (d == 0) {
        if (valid(nx, ny, 0LL, i)) {
          long long int t = 0;
          q.push(tie(nx, ny, t, i));
          vis[nx][ny][0][i] = 1;
        }
      } else {
        if (d == i) {
          if (valid(nx, ny, cnt, i)) {
            q.push(tie(nx, ny, cnt, i));
            vis[nx][ny][cnt][i] = 1;
          }
        } else {
          if (valid(nx, ny, cnt + 1, i)) {
            long long int t = cnt + 1;
            q.push(tie(nx, ny, t, i));
            vis[nx][ny][t][i] = 1;
          }
        }
      }
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (long long int i = 0; i < n; i++) {
    cin >> s[i];
    for (long long int j = 0; j < m; j++) {
      if (s[i][j] == 'S') source = {i, j};
      if (s[i][j] == 'T') dest = {i, j};
    }
  }
  bfs(source.first, source.second, 0, 0);
  for (long long int i = 0; i < 3; i++) {
    for (long long int j = 0; j < 5; j++) {
      if (vis[dest.first][dest.second][i][j]) return cout << "YES\n", 0;
    }
  }
  cout << "NO\n";
  return 0;
}
