[入力例]
3 3 3
#.#
#S.
###
[出力例]
1
※AtCoderテストケースより
[入力例]
3 3 3
###
#S#
###
[出力例]
2
※AtCoderテストケースより
[入力例]
7 7 2
#######
#######
##...##
###S###
##.#.##
###.###
#######
[出力例]
2
※AtCoderテストケースより
[入力例]
20 22 5
######################
######################
######################
######################
###########.##########
##########.#.#########
#########.###.########
########.#####.#######
#######.#.....#.######
######.##.#.#.##.#####
#####.###..S..###.####
######.##.#.#.##.#####
#######.#.....#.######
########.#####.#######
#########.###.########
##########.#.#########
###########.##########
######################
######################
######################
[出力例]
3
[入力例]
55 50 5
.#..####.#.#.####.#.#..######..##...#...#..###..#.
..###.#...#.###.##..###..##.##..##.#.#.####...###.
.#######..#.#.####.###...##..###..#.........#....#
###.......#...#.##.#..#.##.#..#.#.#.#.##.##.#.####
###.##.#####.#.##.##.##.###.######.#....####.....#
#####.....####.......#.##.#..#..##.##.#...#.#.##.#
###.#.#..##..#....#..##...##..###..##.##.#.....#.#
..##.##.#..#.###..#......####.##....#..#.##..#...#
...#..####.#######.#..###..#.###.#..#.##.#...#..#.
#.###.##...#.###.#..####.#.##.....##...#.#.#..#..#
#.##.#########.###..#.##...#..#..#..#.##.####..#..
.##..#.#.....#######.###.#########..#.#.....#.##.#
.....##.#....##.###..........#.#..##..###.##.#.##.
#######..##.#..#...#..#...##.##.##.#.####.#.#.#...
...#####.#.#...#..##...#.##..##.#...##.#...#.....#
.#.#.##...#..##...#..##.##.##..#.###...#....#....#
....#.#.##...##...#.###.##..#..##.#..#..##.##....#
..##.###.#...##.#.#....#.##.####.#####.####..#####
#..#..##.###..#...##.#.#......#.#....##.#.###.##..
#..##..#.###.....####.##..#..#.#.##.#.##.###.###..
##...#....#.###..#.#..#.......###.#.#..##....#..#.
.####.##...####..####....#....#.#.#...##.##.#.#..#
..##...##.#..###..######..##.##.##.#...##....###..
.#.#..#.#.###.##.###..#.#.##.##..##..#..#.###..#.#
.#.#.#.######.#.#...#.....##.....##.##...#.#.##..#
....#.#..####..###.####...##.#.#..#.#.####..#.###.
##..##...#.......###...#.##.#......#.#.##...##.#..
##...#.#.#.#..##.......#.#.#.#.#.#...#.##.#.......
...####.##.#.#...#.#####S.########.#......###.####
....####...#.....#.....#....#.#.#.#..#.#..####..##
#.........#.#.##.#.##..#.##.##......#.#.#....#..##
#..#..####...###.###.#......#...##.#.....####.#...
##.#.##..#..####...#..####.##..####...##..###....#
..######.##.#####...##..###..#.#........##.#.###.#
....###.#.#..#####..#.####.##.#.##..#.###..##.####
.....#..#.##.#.###..#..###.###.#.#...#.#####.#....
..#.#..###...##.##.#.#..##......###..###.#.#...#..
#####..##.##..#..#.#......####.##..##..#####.#.#..
...#.#.###..#.##.#...###...#.#...##...#..#.####...
##.###.#.#.#.....###.#.#.##.##..##..#.#.#.#.#..#.#
##.##.....#....#...#.#...#..##...##..#..##..#...#.
...###...#.###...#.#####..####....#..#.#...#..#.##
##.##...####..#.#####..#.##.#.....#.####.#...#....
#..#.####.#.#.##...#.##....#######..###..####..##.
##.#.###.###..##....####..#...#..#.#.###.###....##
.##...#.###.###..##.##...####..##.....#....#.####.
#.#...####.#...##.#.###...#...##..#.###.##...#..#.
....#.###.#.#..#..##.####.#..##.#..##....#.#...#..
..##..#.##..#..#.########.#.#.#.####..#.##...#.##.
.##...#...#.#....####.##..##..#...###.#####..##..#
##..###.####..#####.#.#.#...##..##..#....##.....#.
....#..##.##..#..#..####..####..##...###.##.#####.
#....##....###..#.####.##....#..#.....#####..##.#.
#.#..####....##..#..#.#.#.###.###.#.###.###..##.##
#.#.#.#.##.#####..#######..#.#...#.#...###.#..#.##
[出力例]
6
[入力例]
110 100 5
......#.#...###...####..#.#..###..#.##.#.#.##.##.##..##...#..#.###.#.##.#..#.###.###..##.....#...#..
#...##.#.#...####..#.#..#.##.##.###...#....##....##....####.#.###....#.##.##.#.##.##.#...#.#####..##
..#..##.#.##...#..#.#..###.###..#.#.####....#..#.###.###.#.#..#.#...##.#...#...##.#.###..#.#.#....##
#...#.###.###.#.####.#..##.#..#...##.####.#.#.###.....#.####..##.....#####.###..#.#.#.......#...###.
...##.####.#.#.#.#########.#......##.###..#..###..#..#....###.##....#.############.###..##..#......#
#.##..##...######.##..#...####..##.####..#.#.###.#.###.#####..#..#..####..##...#..######..#.##...#..
#.#.....###..##.####.#.#...#.#.#......####.....##......#..#...##..##..#######..###....#...##.#.###..
#.#.####..#...#.##...####.#.#....#.#.....#..##..###...#.#######..####..##.#....##.#.######....#...#.
##.##...##..#.####...#....#..#..#....#.####.#####.#...##.#...##..##.....#.#.#..#.#..#.#.#.#.##...#..
#.##.#......#.####...#.##.#.#..#...###.#...#.#.##.#.#...##..#.#.#.#.#####..###.####.#...##.#.....#..
..##.#....##.#.###.###..###.##.####.#.#....#..##.##.#.#######...###########.####.#...#.####.....###.
#.#.#####.#.##.###..#.####.#...#..###.#..#.#..#.##.##....#...###.#...#...###.##.#.#.#.###...#.#..#.#
.###....##..#...###.#...#.######....#.#.....##.###.####.#.##...###.#.##.##.###.#####..#.......#.###.
..###..#.#.#.##......##....##.##......#.#.#..#...##.....##.#.#..##.##..#############.#.###....#####.
#.#.####.###.##.....##.####.#.##....#.#..#.#.##.###...##.###.....###....##.##....###.##.#.#...##.#..
...##.#.#.........##..#.###.#.#....#...#..#.....#..#.#.....##....##.##..#..#...##.#.###...###.######
###.#...#..#.#....##.#.##.##.####.###.#....##.#..#..####...##..##..###...#.###....##.......##.#.##..
..##.########.#.##..##.####..#.#.##..###..###.###..#...##..#...##..#####.....##..#......#.#....###..
###..##.##.###..#####...###...#..#..#....#.#..##.###.##..##.##.##....#..........##..#######..#......
##..##.....#.....#..#####.##.#.###...#...#...######.......##...##....##.#..#.#########..##.###.###..
.###.##.##..#.#.#..#..#..####...#....#...##..##..#...#..#....##..#.#.....#....#.##.#.###...##.#....#
#..#.#.#.##.......##.#.#.........##..#.............###.###.#.#.####..##.##.####.##.##.##....#.#.##..
#.#...#.....###.#...#.#.##...##.###.#.#####.#..########.......#..#......##...##.###.#..#.##.....#...
.#......##..#..#...#...#..###.#.#...###....####..###.#.......#.#.#.....##.#....#######.....#.....#..
#.##..####..#.#.#.#....#.##..##########.##..#.#.#.##.##.#.#.#.#####.##..#####.##....#..###..####.#.#
#....###...#.#.##.#.####.##.#..#.#.#.####......###.....#.#.#....#.#.##.....####.####.........##.#..#
#.#..#.#....##..#.#.###...#.#.....###.#.#.####.##########....##..#....#...###.###.####.####.#.##..#.
.#..#.###...##.#....####.#.##.#.###..##.....##..#...##...##.####..##...#####.#####...##..#.#.#...###
##.#...##....#..#..#..##.#....#.##...#.#.#..##.#..#.###.....##.#.####..##.#.#.#####.....#####.####..
...#.#.#.#####..#..##...##.#.#...#.##.#..#.#..####.#.....###.#.##..###.#...#...#.....#####.#..##.#..
##......#.#.#.#..#..######...#####.##..#..#..#.#.#.###......#.####..##....#.#..###......##.##.#..#.#
####.##.#######..#.#....#.#...###.###.#.#....#..#.###...###..#.#..##.##.#.##....###...#...##.#.#...#
..######.#.#...#..##.##.####...#####...####..#####..#.#...#.#...#.###.#.#.####...#..##.#.##.#..#....
#####..#.####.#..#...##.#....##....####.#...#...##.#.#####.####..#.####..##..###..##...###..#.##.#..
#..###.........##.#.#...#..##.##..##...#.##....##...#......#.#..#..#.#.#.##...##.##..#####...###...#
##.##.##...####...#.#####....#.####..#.###...#.###.#.##..##..####.##...#..#.#####..##.#..####...#...
..###.....##.#.#####.###..##.#..##..##.#.###.##.#.#..#..#.#.###..##.###.##.##...######.##.#...##.#..
...#.#....#.#.#.....####.##..###..####.#.#..#.#..#.##.#.#.#..#...#.#.#.#.##..##......####.######.#..
#.#...#..#######....##.#.#######.#.##.##.....#...#.####..#.##..#..##.#.#.#...#..#.####..#.#.#####..#
##.#.....##...#...#.###...###.####.######.###.##..###..#...##..###...#..###..#..###..###..#..#...#.#
.#.##..####.#.#....##.#..#..##...##......####.#####.##...#########..#..##...##.#..##...#...#.#####..
.#.#####.#...#...#..##.#.......####.###.##.#.#....##...###..#...#.#.#.#.#...##.#....#..#.....##..#..
...##..#####.#..........#..##.#.##.#..###.####.#.##..###.###...#####.##.#....#####.#.##..#.##.#....#
#....##.##..#....##..#.#.##.#.#.#..#..###.####.#.###.#.##.####..##..#..#..#..#..#.##...####..#.##.#.
#..#..#..#..####.#.#.#.#.##..##...#..#........#...#.#..#.##.......#.##...##..#.#.##....#....#..###.#
.#.#.##...###...##....###....##..#.#..#.##.##..####..#.##.#.....#..#####......#...##....#..##.#...##
#...#..##......##......#....##..#.#....#..##..#.##..#.##.###.###.##..#..#....##...#.#....##.##..##.#
##...#..##..#..#.#.##.###.##.#..###.##.#####.##.####..#..##.#..#.#.#....#.####.....##.##.######.#.#.
####..#..#.##..#.###.##.###.##.##..#.#.#..#..#####.#..#.#...##..#...#.##.##....##....#.#..#..####.#.
##...#.###..#..###.###...#.#..##.#....###.##..#.#.#S#.#...###.#.###.###.##.#.#.....#.......#....#..#
..##.#.###..###...###.#....#...#...#.##.#.....##.#..##..#.####..##.##..##...#.##.#.#...#....#.#.....
####.###..##.##....##.##...##..###..###..#.#..##..####..#.#.....###.#.##...##..#.########..#.####..#
..#..######.##.###.####..#.#.##.#...##.....#..........##.##.#.....#.###.###..#.....##.#..#...####...
#.#.....####..##..#..#..#...###.##..#...#...########.#.###.#.....#####...#...#..##......###.##..#...
###.#.....##..#..##.....##.##.#######...#.....##....##.##....#.##..##.##.#..##.##.###.#.#.#...#.####
..#.#####.#...#.#.###....#.###..##..##.####.....##.####.##.#..###################.#.#.####.....###.#
#..####.##.#..##...#..###..#####.#..#...#.#.#...#...####.#.#.##.##.#...#...##..###.#..#...#.#.#.####
#####.##.#..###..#...#..#.#...#.###.##..#.#.#......#..#.#.#.#...##.###.##.####...###.##.####...#...#
#....#.##.#..#..###.#.######...##.###..####.##.#.#.##.#.##.##.###.##...###...##..#.#.#.#....##..#..#
.##.....#######...#....#...#####...#.#####.##..#...#..#....##..#####..##.##.#...#..##.###.#####...#.
#.#.##..#.#.#.####.###.#.##...#.####.....##..###..#.#..##..#..##.#..#.#######.###.#...##..#####..#..
..#.....###...#..#.#...#..##...##.#.......#...#...#..#.#.#....#..#....##.#..##.##..#.##..##..####.##
###.##.#.##..##..#..###.##.#.####..#..#.##....#.###.#.#...#..#..#..##...##.##..#.##...####...####..#
..##......#.##.###.#...#.########.....#####.###.###.#.#..#.##.#..##..####.#..#...#..#.#..#.###.##...
...####.......###.###.....##...#.#.####.....#########.#..#..#.####..###......#....#.##.....###..###.
.#...#.#..##.###.#.###...###..#.###..####.##.##...#.#.#.....#.#.#..#####....########.#.#.##.#....#..
###.......##.##.#..####.###.##.#####.#.#.....#..####..##..##.######.#...#..#.#.....#....#...#..##..#
.#..#....###.#....###..##...###...###..#.#..#.#.#####.#...#.##..#.#...##.###.####..#.#..#.#..#.#.###
....###....#..#.##...#####........##..##.#...####..##......#.#......#.#.##.###..####.#...##..#...#..
#######...#.........###.####.#.#...###.#.#.###.###.##..#.#....##.###..##...##.##..###..####.#.##.##.
.####.#.##.#..#...#.##.#..#.#.##.#...##...###.#.##...#....#####.#.##..#.#.####...#..#.#####.#.####.#
..###.#...#..#######.####.###.#..###.#.#.#####...##.###.#..#..#.....#.###.##.##...##..#.#.##.#.#...#
#....#..###.##...##.#.#.###.#..##..#.##.#...##.......#.#..#.#...##.#...#..#.#....#...#...#......##..
.#.....####.#.####..#..#####.####..######.#..#...##..#######.#########.#.##....#.#.....##.####.#..##
#....##..###.##..##...##....######..###..#.#.#.#...#.##..###.#..#.######.#####.#.####..#.##..#.##..#
....#..#..###.#.#..##.####.#####.####.######..#####.##.#.#.#...#..##..##.##.#.##.....#.#.#.##.##..#.
#.#.##..###.####......#....#.#.#..#.....###.#..##........##.##.########.#.##.###.#..#.##.#.#..#.####
#..###..#.....##...##....###..#.##.#.#..#....###.##..######.....#.#.##.##.#..##...#...#.....###.####
#...#.#..#.#.......#........###.####...#.#.#...#...######...#.####.#...##..###....##.###...###.#...#
#....#..###.#.###.##.#..####..#..#######..#.##..##.#.#####.#..##.#.##..##...#.######..###.#..#...##.
.#.#..###..#..##..###.....##..#.#.#.#..#.#.####.#..####....#...#..######.###.##..##.#.##.###.##..##.
..##.##..##..#....##..##.........#######.#.#.#..##.#.#....####.#.#.##.#.####.#..###.####..####.#..#.
..#.#..####.#..##..........#..###..####..#.######.#.#.#.####.#####..######.##.#.####....###.##..#..#
##.....#..##.##.###..#.###########.#.#.#..#.####.##....##..##.##...#..#####...#...#######....#....#.
...#.##.....##.#..##...#.....#.#..####....#.#.#...#.###.#.##..###...#...#.##.#..####..###.###...#.##
###.#..#.##...#.##.##...##...##.###.#.#######.#....#.#.#.#.....#..#..#..##..##..#.#..#.#.##.#...##..
.##.#.#.#.#.#.##.##.#.###.....#.#..#.###.#.####...#.##...#..###.#.###..###.....#...#..#.######.#..#.
.#...#.#..###.##.#.#..####.#..##.###.##...#.##.##..#...###..#.....#...#.##.#....#..#.####..#.#.##..#
#.##.....###.#...##.....#..#.#..#.##.....####.#.##.##...###...#.##.#.#.##.###..#####.###.##...#####.
........###..####....##.##.#.......#..###.##....#..###.#.##.##.#####.#.##.#....###.....##.#.##...###
##..##..##.##.#.#.#.#########.#.##..#.#.##..##..############..#..#.#.##..##.###.#.#####...#####...#.
.#..##.#...###..##...###.#####.##..#######.####.#..#.##.###.##.....##.###.....##.####...##.#.#.#.#.#
...#...####.#......##.####..##.#.#.###.#.#.##...#..##.#.##.##....##..#..##.#....#######.#.###..#.#..
..###.##.###..#.####.##.##....##.##.##.#.##.#####...###...##...##.#.#..#.##..........#..##.#..#....#
###.#..#...####.###.#.######......#...#....##.#.##..#.#..######.##.###.#.#.#....##.##.##...#.....###
.#.##..#..###.....#.###...#.#...#.#.#.#..........##.##....##.###.##.###.###..#...#..####..####..##.#
###..####.#..#..#......#.##..#...#...#.....###.#..##..#....##..###.#..##.......#.###.#.....#.#####.#
.#.#..#..#....#...#..#####...##.#.#....#....##..####..###..###...#.#..#...######.#..#.##..#..#...###
.#.##.#......#..####....#..#.#.#.#..#.#...#.....###.##.##..##..#...##........##.##..#.#####.##.##.#.
..#.#.##.##.####.#.###..#######..####.#..####....#.##.#.....#.#..######....##.#..#.##.#.####.######.
####.##....#...####..#######..##.#.#..##.##.###..#.#.##..###.##.#......#.....#....#.#..###.....##...
...#..#..#......##.#.##.#.#######...####.#..#.#.#.#.##..#####.....##....#.#..#..#..#.##.#.#.####..#.
.###.##..##..###..#..#.#####.##...########..#.#.#...#######.#..#.###.#.#.#...#.#.#.###.#.#######....
..###...##..#.#.##..#..#..#####..#..#...##..#.#....#...#..#..#..#..##.#.#.#.#.##....#.#...#.#####.##
.#....#....#.##.###..#..##...#....##..#.####.##.#..##.##..#.##.....##..#...#.#......#..###..##..##..
##..##..#...#.###.#.#.##.####.#...##..#..##.###.##..#.#...##....#.######.#..#.....#..#..#....#######
.####.###.#######.#.#####..###.#####.##...##.###...#..#.#......##.....#####.#..#..#.#####.#..###.###
.##.#..#.#####..#.#.####...#.#..#....#..#...##...###..#........######...#..####.#..#.#.#.#...####.#.
....#.#.##...#.#..###...#....###.###.#.#..#.#....#.#.####.....####..#.#####.....#...#.##.####.##....
#.#..#####.....#.###..#.#######.###......##.##.#...##.##..##....#....#...####..###.#.#.####...#.#.##
[出力例]
11