#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, 0, 0, 1};
int dy[] = {0, -1, 1, 0};
int n, m;
bool valid(int i, int j) { return i >= 0 && j >= 0 && i < n && j < m; }
int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  string board[n];
  bool visit[n][m][5][5];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      for (int k = 0; k < 5; k++)
        for (int l = 0; l < 5; l++) visit[i][j][k][l] = false;
  for (int i = 0; i < n; i++) cin >> board[i];
  stack<pair<pair<int, int>, pair<int, int> > > st;
  pair<int, int> goal;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (board[i][j] == 'T')
        goal = {i, j};
      else if (board[i][j] == 'S') {
        st.push({{-1, 0}, {i, j}});
        visit[i][j][0][0] = true;
      }
  bool ans = false;
  while (st.size() > 0) {
    auto current = st.top();
    st.pop();
    int turns = current.first.second, prevdir = current.first.first;
    auto position = current.second;
    if (position == goal) {
      ans = true;
      break;
    }
    if (prevdir == -1) {
      for (int k = 0; k < 4; k++) {
        int x = position.first + dx[k];
        int y = position.second + dy[k];
        if (valid(x, y) && !visit[x][y][k + 1][turns] && board[x][y] != '*') {
          visit[x][y][k + 1][turns] = true;
          st.push({{k, turns}, {x, y}});
        }
      }
    } else {
      int x = position.first + dx[prevdir];
      int y = position.second + dy[prevdir];
      if (valid(x, y) && !visit[x][y][prevdir + 1][turns] &&
          board[x][y] != '*') {
        visit[x][y][prevdir + 1][turns] = true;
        st.push({{prevdir, turns}, {x, y}});
      }
      if (turns < 2) {
        for (int k = 0; k < 4; k++) {
          x = position.first + dx[k];
          y = position.second + dy[k];
          if (valid(x, y) && !visit[x][y][k + 1][turns + 1] &&
              board[x][y] != '*') {
            visit[x][y][k + 1][turns + 1] = true;
            st.push({{k, turns + 1}, {x, y}});
          }
        }
      }
    }
  }
  cout << (ans ? "YES" : "NO");
}
