#include <bits/stdc++.h>
using namespace std;
using ll = long long;
class field {
  int n, m;
  vector<string> a;
  bool check(int x, int y) {
    return x >= 0 && x < n && y >= 0 && y < m && a[x][y] != '*';
  }
  const int inf = 1e9;
  int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};

 public:
  field() {
    cin >> n >> m;
    a.resize(n);
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
    }
  }
  void solve() {
    int xs = 0, ys = 0, xt = 0, yt = 0;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        if (a[i][j] == 'S') {
          xs = i, ys = j;
        }
        if (a[i][j] == 'T') {
          xt = i, yt = j;
        }
      }
    }
    vector<vector<vector<int> > > dist(
        n, vector<vector<int> >(m, vector<int>(4, inf)));
    dist[xs][ys][0] = 0;
    dist[xs][ys][1] = 0;
    dist[xs][ys][2] = 0;
    dist[xs][ys][3] = 0;
    struct state {
      int x, y, dir;
    };
    queue<state> q;
    q.push(state({xs, ys, 0}));
    q.push(state({xs, ys, 1}));
    q.push(state({xs, ys, 2}));
    q.push(state({xs, ys, 3}));
    while (!q.empty()) {
      state st = q.front();
      q.pop();
      for (int d = 0; d < 4; ++d) {
        int x = st.x + dx[d], y = st.y + dy[d];
        if (!check(x, y)) continue;
        if (dist[x][y][d] > dist[st.x][st.y][st.dir] + (st.dir != d)) {
          dist[x][y][d] = dist[st.x][st.y][st.dir] + (st.dir != d);
          q.push(state({x, y, d}));
        }
      }
    }
    if (dist[xt][yt][0] <= 2 || dist[xt][yt][1] <= 2 || dist[xt][yt][2] <= 2 ||
        dist[xt][yt][3] <= 2) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  field().solve();
}
