Perspectives I


Submit solution

Points: 1
Time limit: 1.5s
Memory limit: 256M

Author:
Problem type
Allowed languages
C, C++, Java, Python

Minecraft is a game about mining resources and building structures out of cubes. After a long day of mining diamonds on the ACPC Minecraft server, Saadan is feeling rich and wants to show off his wealth to his friends, Shashwat and Hamza.

To flex, he crafts his diamonds into blocks and builds a structure that is exactly 1 block tall. He then takes two screenshots to share on Discord:

  • One from the front view (the XY-plane)

  • One from the side view (the YZ-plane)

From these two perspectives, it is not immediately clear how many diamond blocks Saadan's structure actually contains. Hamza, impressed, wants to determine the maximum possible number of blocks that could match both screenshots.

For example, if the screenshots look like:

Image 1 Image 2

Then Saadan's structure could contain at most 15 diamond blocks, as shown below:

Image 3

Input

The first line contains an integer c (1 \leq c \leq 10^5), the number of columns visible in each screenshot.

The second line contains a string S_f of length c, representing the front view (the XY-plane, indexes = X).

The third line contains a string S_s of length c, representing the side view (the YZ-plane, indexes = Z).

Each character of S_f and S_s is either:

  • #: A diamond block
  • .: Empty space

Output

Output the maximum number of diamond blocks Saadan could have used in this structure, given these two perspectives.

Clarifications

  • Each perspective will have at least 1 diamond block.

Example

Input 1
6
###.##
..###.
Output 1
15

This is the example as given above.

Input 2
8
########
########
Output 2
64
Input 3
4
#.##
#.#.
Output 3
6

Comments

There are no comments at the moment.