#include <bits/stdc++.h>
using namespace std;
char c[1005][1005];
int dp[1005][1005], ini, inj;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int i, j, k, ans = 0, sum = 0, a[100005] = {0}, ma = 0, mi = 1000000000, n, m,
               tni, tnj;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      cin >> c[i][j];
      if (c[i][j] == 'S') {
        ini = i;
        inj = j;
      }
      if (c[i][j] == 'T') {
        tni = i;
        tnj = j;
      }
      dp[i][j] = 100000;
    }
  }
  dp[ini][inj] = 0;
  for (j = inj + 1; j < m; j++) {
    if (c[ini][j] == '.') {
      dp[ini][j] = 0;
    }
    if (c[ini][j] == 'T') {
      cout << "YES";
      return 0;
    }
    if (c[ini][j] == '*') {
      break;
    }
  }
  for (j = inj - 1; j >= 0; j--) {
    if (c[ini][j] == '.') {
      dp[ini][j] = 0;
    }
    if (c[ini][j] == 'T') {
      cout << "YES";
      return 0;
    }
    if (c[ini][j] == '*') {
      break;
    }
  }
  for (i = ini + 1; i < n; i++) {
    if (c[i][inj] == '.') {
      dp[i][inj] = 0;
    }
    if (c[i][inj] == 'T') {
      cout << "YES";
      return 0;
    }
    if (c[i][inj] == '*') {
      break;
    }
  }
  for (i = ini - 1; i >= 0; i--) {
    if (c[i][inj] == '.') {
      dp[i][inj] = 0;
    }
    if (c[i][inj] == 'T') {
      cout << "YES";
      return 0;
    }
    if (c[i][inj] == '*') {
      break;
    }
  }
  for (j = inj + 1; j < m; j++) {
    if (dp[ini][j] == 0) {
      int p, t;
      for (p = ini + 1; p < n; p++) {
        if (c[p][j] == '.') {
          dp[p][j] = 1;
        }
        if (c[p][j] == 'T') {
          cout << "YES";
          return 0;
        }
        if (c[p][j] == '*') {
          break;
        }
      }
      for (p = ini - 1; p >= 0; p--) {
        if (c[p][j] == '.') {
          dp[p][j] = 1;
        }
        if (c[p][j] == 'T') {
          cout << "YES";
          return 0;
        }
        if (c[p][j] == '*') {
          break;
        }
      }
    } else {
      break;
    }
  }
  for (j = inj - 1; j >= 0; j--) {
    if (dp[ini][j] == 0) {
      int p, t;
      for (p = ini + 1; p < n; p++) {
        if (c[p][j] == '.') {
          dp[p][j] = 1;
        }
        if (c[p][j] == 'T') {
          cout << "YES";
          return 0;
        }
        if (c[p][j] == '*') {
          break;
        }
      }
      for (p = ini - 1; p >= 0; p--) {
        if (c[p][j] == '.') {
          dp[p][j] = 1;
        }
        if (c[p][j] == 'T') {
          cout << "YES";
          return 0;
        }
        if (c[p][j] == '*') {
          break;
        }
      }
    } else {
      break;
    }
  }
  for (i = ini + 1; i < n; i++) {
    if (dp[i][inj] == 0) {
      int p, t;
      for (p = inj + 1; p < m; p++) {
        if (c[i][p] == '*') {
          break;
        }
        if (c[i][p] == '.') {
          dp[i][p] = 1;
        }
        if (c[i][p] == 'T') {
          cout << "YES";
          return 0;
        }
      }
      for (p = inj - 1; p >= 0; p--) {
        if (c[i][p] == '*') {
          break;
        }
        if (c[i][p] == '.') {
          dp[i][p] = 1;
        }
        if (c[i][p] == 'T') {
          cout << "YES";
          return 0;
        }
      }
    } else {
      break;
    }
  }
  for (i = ini - 1; i >= 0; i--) {
    if (dp[i][inj] == 0) {
      int p, t;
      for (p = inj + 1; p < m; p++) {
        if (c[i][p] == '*') {
          break;
        }
        if (c[i][p] == '.') {
          dp[i][p] = 1;
        }
        if (c[i][p] == 'T') {
          cout << "YES";
          return 0;
        }
      }
      for (p = inj - 1; p >= 0; p--) {
        if (c[i][p] == '*') {
          break;
        }
        if (c[i][p] == '.') {
          dp[i][p] = 1;
        }
        if (c[i][p] == 'T') {
          cout << "YES";
          return 0;
        }
      }
    } else {
      break;
    }
  }
  for (i = tni + 1; i < n; i++) {
    if (dp[i][tnj] == 1 || dp[i][tnj] == 0) {
      cout << "YES";
      return 0;
    }
    if (c[i][tnj] == '*') {
      break;
    }
  }
  for (i = tni - 1; i >= 0; i--) {
    if (dp[i][tnj] == 1 || dp[i][tnj] == 0) {
      cout << "YES";
      return 0;
    }
    if (c[i][tnj] == '*') {
      break;
    }
  }
  for (j = tnj + 1; j < m; j++) {
    if (dp[tni][j] == 1 || dp[tni][j] == 0) {
      cout << "YES";
      return 0;
    }
    if (c[tni][j] == '*') {
      break;
    }
  }
  for (j = tnj - 1; j >= 0; j--) {
    if (dp[tni][j] == 1 || dp[tni][j] == 0) {
      cout << "YES";
      return 0;
    }
    if (c[tni][j] == '*') {
      break;
    }
  }
  cout << "NO";
  return 0;
  return 0;
}
