Under construction

Still being built. Things may change

Trianglane

Interview

Time limit1sMemory limit1024 MB

Summary
Given a two-row strip of unit triangles, each marked black or white, find the perimeter of the black region in meters.
Level

Easy3 of 10

Topics
Implementation, Simulation
Solved
No attempts yet

Problem

Bocchi the Builder has just finished constructing her latest project: a pathway made of two rows of white equilateral triangular tiles. However, at the last moment, disaster struck, and she accidentally spilled black paint on some of the tiles. Now she must buy warning tape to block off the wet areas. Can you help her determine how many meters of tape she needs?

The first triangle always points upward, and any two adjacent tiles (tiles that share a side) point in opposite directions. Every triangle has a side length of 1 meter.

Input

The first line contains one integer CC, the number of columns.

The next two lines each contain CC integers separated by spaces. Each integer gives the color of a tile, where 1 means the tile is black and 0 means the tile is white.

Output

Output a single integer, the length of tape Bocchi must buy in meters.

Constraints

1≤C≤200 0001 \le C \le 200\,000

Examples2

  1. Example 1

    Input
    5
    1 0 1 0 1
    0 0 0 0 0
    
    Expected output
    9
    
  2. Example 2

    Input
    7
    0 0 1 1 0 1 0
    0 0 1 0 1 0 0
    
    Expected output
    11