An imaging device furnishes digital images of two machined surfaces that
eventually be assembled in contact with each other. The roughness of
this final contact is to be estimated. A digital image is composed of
the two characters, X
and
(space). There are always X
Column X
s.
Digital-Image View of Surfaces
XXXX XXXXX
X XXXXXXXX
XXXXX XXXXXX
XX X
XXXXXXX XXXXXX
. . .
. . .
. . .
XXXXX XXXXX
In each row of the image, there can be zero or more space characters
separating the left from the right surface. There will be no more than
one region of blanks in any row. For each image given, your program has
to determine the total "void" that will exist after the left and right
surfaces have been brought into contact. The "void" is the total count
of spaces that remain. The two surfaces are brought into contact by
displacing them strictly horizontally towards each other until a
rightmost X
of the left surface of some row is immediately to the left
of the leftmost X
of the right surface in that row. The original image
may show the two surfaces already in contact, in which case no
displacement is needed.
Input Specification
The input consists of a series of digital images.
Each data set for a digital image has the following format:
a positive integer
X
s, then zero or more
spaces, followed by one or more X
s.
The end of data is indicated by the single digit 0
.
Output Specification
For each image output the value of "void", one per line.
Sample Input
4
XXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXX
2
XXXXXXXXX XXXXXXXXXXXX
XXXXXXXXX XXXXXXXXXXXXXX
3
XXXX XXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXX XXXXX
XXXXXXXXX XXXXXXXXXXX
2
X X
XXXXXXX XXXXXXXXXXXXXX
0
Sample Output
0
2
2
19
Comments