1757 - Apple 偷苹果

Input

Output

每组数据输出一个整数表示小偷最多能够得到的苹果数

Examples

Input

3 
T3333.
#####S
######
######
######

####..
.3.3..
33.T.S
######
######

##3###
##.##3
TS3###
##.###
##3###

Output

9
12
0

Hint

对于第三个样例,小Y 可以永远停留在他右边的苹果树上,那么小偷就再也偷不到苹果 了,此时Game Over 。

Time Limit 1 second
Memory Limit 128 MB
Discuss Stats
上一题 下一题