#include <bits/stdc++.h>
using namespace std;
bool v[1005][1005][4][3];
char grid[1005][1005];
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int n, m;
int xx, yy;
bool dfs(int x, int y, int dir, int turns) {
  if (x < 0 || x == n || y < 0 || y == m || turns > 2 || grid[x][y] == '*')
    return false;
  if (v[x][y][dir][turns]) return false;
  v[x][y][dir][turns] = true;
  if (x == xx && y == yy) return true;
  bool can = false;
  for (int i = 0; i < 4; i++)
    can |= dfs(x + dx[i], y + dy[i], i, turns + (i != dir));
  return can;
}
int main() {
  cin >> n >> m;
  pair<int, int> second, t;
  for (int i = 0; i < n; i++) {
    scanf("%s", grid[i]);
    for (int j = 0; j < m; j++) {
      if (grid[i][j] == 'S')
        second = make_pair(i, j);
      else if (grid[i][j] == 'T')
        t = make_pair(i, j);
    }
  }
  xx = t.first, yy = t.second;
  if (dfs(second.first, second.second, 0, 0) ||
      dfs(second.first, second.second, 1, 0) ||
      dfs(second.first, second.second, 2, 0) ||
      dfs(second.first, second.second, 3, 0))
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
