#include <bits/stdc++.h>
using namespace std;
const int mx = 1e3;
bool vis[mx + 3][mx + 3];
char arr[mx + 3][mx + 3];
int n, m;
int sx, sy, tx, ty;
void dfs1(int x, int y) {
  if (x >= 0 and x < n and y >= 0 and y < m and arr[x][y] != '*' and
      !vis[x][y]) {
    vis[x][y] = true;
    dfs1(x, y - 1);
    dfs1(x, y + 1);
  }
}
void dfs2(int x, int y) {
  if (x >= 0 and x < n and y >= 0 and y < m and arr[x][y] != '*' and
      !vis[x][y]) {
    vis[x][y] = true;
    dfs2(x - 1, y);
    dfs2(x + 1, y);
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> arr[i][j];
      if (arr[i][j] == 'S') {
        sx = i;
        sy = j;
      }
      if (arr[i][j] == 'T') {
        tx = i;
        ty = j;
      }
    }
  }
  dfs1(sx, sy);
  vis[sx][sy] = false;
  dfs2(sx, sy);
  if (vis[tx][ty])
    cout << "YES" << endl;
  else {
    queue<int> q;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        if (vis[i][j]) {
          q.push(i);
          q.push(j);
        }
      }
    }
    while (!q.empty()) {
      int x = q.front();
      q.pop();
      int y = q.front();
      q.pop();
      vis[x][y] = false;
      dfs1(x, y);
      vis[x][y] = false;
      dfs2(x, y);
    }
    if (vis[tx][ty])
      cout << "YES" << endl;
    else {
      queue<int> q;
      for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
          if (vis[i][j]) {
            q.push(i);
            q.push(j);
          }
        }
      }
      while (!q.empty()) {
        int x = q.front();
        q.pop();
        int y = q.front();
        q.pop();
        vis[x][y] = false;
        dfs1(x, y);
        vis[x][y] = false;
        dfs2(x, y);
      }
      cout << (vis[tx][ty] ? "YES" : "NO") << endl;
    }
  }
}
