Under construction

Still being built. Things may change

Destiny

Interview

Time limit1sMemory limit1024 MB

Summary
Count the left-right sock pairs whose colors differ, given X left socks, X right socks, and K possible colors.
Level

Easy3 of 10

Topics
Array, Math
Solved
No attempts yet

Problem

Dongwon has 2X2X socks. Socks 11 through XX are for the left foot, and socks X+1X+1 through 2X2X are for the right foot.

There are KK sock colors, called color 11, color 22, ⋯\cdots, color KK. The color of the ii-th sock is color AiA_i.

Dongwon wants to wear one left sock and one right sock. The two socks must have different colors. How many ways can Dongwon put on socks this way?

Input

The first line contains XX and KK, separated by a space.

The second line contains 2X2X integers A1,A2,⋯ ,A2XA_1, A_2, \cdots, A_{2X}, separated by spaces.

Output

Print the number of ways Dongwon can put on a left sock and a right sock so that their colors differ. The answer can exceed the range of a 32-bit integer.

Constraints

  • 1≤X≤100 0001 \le X \le 100\,000
  • 1≤K≤10 0001 \le K \le 10\,000
  • 1≤Ai≤K1 \le A_i \le K (1≤i≤2X1 \le i \le 2X)

Examples4

  1. Example 1

    Input
    4 5
    1 3 2 4 3 1 1 5
    
    Expected output
    13
    
  2. Example 2

    Input
    5 2
    1 2 2 1 2 1 1 1 1 2
    
    Expected output
    14
    
  3. Example 3

    Input
    5 3
    1 1 1 1 1 3 3 3 3 3
    
    Expected output
    25
    
  4. Example 4

    Input
    5 3
    2 2 2 2 2 2 2 2 2 2
    
    Expected output
    0