#include <bits/stdc++.h>
using namespace std;
long long n, m;
int arr[1100][1100];
short int color[1100][1100];
deque<pair<pair<int, int>, pair<int, int> > > deq;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int x1, x2, y1, y2, i, j;
  string s;
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    cin >> s;
    for (j = 0; j < m; j++) {
      color[i][j + 1] = 10;
      if (s[j] == '*')
        arr[i][j + 1] = 1;
      else if (s[j] == 'S') {
        x1 = i;
        y1 = j + 1;
      } else if (s[j] == 'T') {
        x2 = i;
        y2 = j + 1;
      }
    }
  }
  deq.push_back({{x1 - 1, y1}, {1, 0}});
  deq.push_back({{x1, y1 + 1}, {2, 0}});
  deq.push_back({{x1 + 1, y1}, {3, 0}});
  deq.push_back({{x1, y1 - 1}, {4, 0}});
  int tom = 4;
  while (tom > 0) {
    int x = (deq.front()).first.first, y = (deq.front()).first.second,
        t = (deq.front()).second.first, kol = (deq.front()).second.second;
    deq.pop_front();
    tom--;
    if (kol > 2) continue;
    if (arr[x][y] == 1) continue;
    if ((x < 1) || (n < x) || (y < 1) || (m < y)) continue;
    if ((color[x][y] < kol)) continue;
    if ((x == x2) && (y == y2)) {
      cout << "YES";
      return 0;
    }
    color[x][y] = kol;
    if ((kol + (t != 1) <= 2) && (color[x - 1][y] > kol + (t != 1)))
      tom++, deq.push_back({{x - 1, y}, {1, kol + (t != 1)}});
    if ((kol + (t != 2) <= 2) && (color[x][y + 1] > kol + (t != 2)))
      tom++, deq.push_back({{x, y + 1}, {2, kol + (t != 2)}});
    if ((kol + (t != 3) <= 2) && (color[x + 1][y] > kol + (t != 3)))
      tom++, deq.push_back({{x + 1, y}, {3, kol + (t != 3)}});
    if ((kol + (t != 4) <= 2) && (color[x][y - 1] > kol + (t != 4)))
      tom++, deq.push_back({{x, y - 1}, {4, kol + (t != 4)}});
  }
  cout << "NO";
  return 0;
}
