In the event of technical difficulties with Szkopuł, please contact us via email at email@example.com.
If you are familiar with IRC chat, the support team is also reachable on PIRC network (
#szkopul channel. If you are not, just use email.
Please do not ask us things like "how to solve task XYZ?".
Please remember that the support team has to sleep sometimes or go to work in real life.
Two urgent cake orders came to Byteasar's confectionery. As we all know, cakes have layers. The confectionery offers different kinds of layers and each cake contains exactly one layer of each kind. A cake order specifies a sequence in which the layers are to be placed.
Byteasar hires confectioners; the -th confectioner (for ) can prepare only a layer of the -th kind. Each confectioner places his layer in a single minute (during that time he or she can work on a single cake only). Layers of a cake are to be placed one by one, however two cakes can be processed in parallel. How much time will it take to fulfill the two given cake orders, assuming that the cakes are produced in an optimal manner?
The first line of input contains a single integer (). Two lines follow containing a description of the first and the second cake order respectively. Each cake order is a sequence of pairwise distinct integers of value between and , describing the subsequent layers of the ordered cake starting from the topmost layer.
The first and only line of output should contain a single integer: the number of minutes needed to produce the two ordered cakes.
For the input data:
3 1 2 3 3 2 1
the correct result is:
Task author: Anna Zych.