#include <iostream>
#include <unordered_map>
#include <string>
using namespace std;
const int N = 60;
int r, c;
string g[N];
int sx, sy, ex, ey;
int dx[] = { -1, 1, 0, 0 };
int dy[] = { 0, 0, -1, 1 };
bool st1[N][N] = { 0, };
bool st2[N][N] = { 0, };
unordered_map<char, string> h{
{'+', "1111"}, {'-', "0011"}, {'|', "1100"},
{'.', "0100"}, {'S', "1111"}, {'T', "1111"}
};
void dfs1(int x, int y)
{
st1[x][y] = true;
for (int i = 0; i < 4; i++)
{
if (h[g[x][y]][i] == '0') continue;
int xx = x + dx[i];
int yy = y + dy[i];
if (xx < 0 || xx >= r || yy < 0 || yy >= c) continue;
if (st1[xx][yy]) continue;
if (g[xx][yy] == '#') continue;
dfs1(xx, yy);
}
}
int change(int i)
{
if (i == 0)return 1;
if (i == 1) return 0;
if (i == 2) return 3;
if (i == 3) return 2;
}
void dfs2(int x, int y)
{
st2[x][y] = true;
for (int i = 0; i < 4; i++)
{
int xx = x + dx[i];
int yy = y + dy[i];
if (xx < 0 || xx >= r || yy < 0 || yy >= c) continue;
if (st2[xx][yy]) continue;
if (g[xx][yy] == '#') continue;
int j = change(i);
if (h[g[xx][yy]][j] == '0') continue;
dfs2(xx, yy);
}
}
int main()
{
cin >> r >> c;
for (int i = 0; i < r; i++)
{
cin >> g[i];
}
for (int i = 0; i < r; i++)
{
for (int j = 0; j < c; j++)
{
if (g[i][j] == 'S')
{
sx = i;
sy = j;
}
if (g[i][j] == 'T')
{
ex = i;
ey = j;
}
}
}
dfs1(sx, sy);
if (!st1[ex][ey])
{
cout << "I'm stuck!" << endl;
return 0;
}
dfs2(ex, ey);
int res = 0;
for (int i = 0; i < r; i++)
{
for (int j = 0; j < c; j++)
{
if (st1[i][j] && !st2[i][j]) res++;
}
}
cout << res << endl;
return 0;
}