#include <iostream>
using namespace std;
const int N = 60;
int st1[N][N], st2[N][N];
char graph[N][N];
int n, m;
int edx, edy;
int stx, sty;
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
bool check(int x, int y, int i){
if(graph[x][y] == '+' || graph[x][y] =='S' || graph[x][y] == 'T') return true;
if(graph[x][y] == '-' && (i % 2) == 1) return true;
if(graph[x][y] == '|' && (i % 2) == 0) return true;
if(graph[x][y] == '.' && i == 2) return true;
return false;
}
void dfs1(int x, int y){
st1[x][y] = true;
for(int i = 0; i < 4; i ++ ){
int xx = x + dx[i], yy = y + dy[i];
if(xx < 0 || xx >= n || yy < 0 || yy >= m) continue;
if(graph[xx][yy] == '#' || st1[xx][yy]) continue;
if(check(x, y, i)) dfs1(xx, yy);
}
}
void dfs2(int x, int y){
st2[x][y] = true;
for(int i = 0; i < 4; i ++ ){
int xx = x + dx[i], yy = y + dy[i];
if(xx < 0 || xx >= n || yy < 0 || yy >= m) continue;
if(graph[xx][yy] == '#' || st2[xx][yy]) continue;
if(check(xx, yy, i ^ 2)) dfs2(xx, yy);
}
}
int main(){
cin >> n >> m;
for(int i = 0; i < n; i ++ ){
for(int j = 0; j < m; j ++ ){
cin >> graph[i][j];
if(graph[i][j] == 'S') stx = i, sty = j;
else if(graph[i][j] == 'T') edx = i, edy = j;
}
}
dfs1(stx, sty);
if(!st1[edx][edy]) cout << "I'm stuck!" << endl;
else{
dfs2(edx, edy);
int res = 0;
for(int i = 0; i < n; i ++ ){
for(int j = 0; j < m; j ++ ) res += (st1[i][j] && !st2[i][j]);
}
cout << res << endl;
}
return 0;
}