Under construction

Still being built. Things may change

Hamburger Sort

Time limit1sMemory limit1024 MB

Summary
Given a length-3 string holding (, 1, and ) once each, find the fewest moves that place one character next to another to form (1).
Level

Easy2 of 10

Topics
String, Implementation
Solved
No attempts yet

Problem

A hamburger string is a string where the three characters (, 1, ) appear in that order.

Junhwi made a string SS by arranging the three characters (, 1, ) in any order. He can repeat this process: pick one character he wants from the string, then place it before or after another character. Find the minimum number of times he must repeat this process to turn SS into a hamburger string.

Input

A string SS is given. The length of SS is 33, and it contains each of (, 1, ) exactly once.

Output

Print the minimum number of times the process must be repeated to turn SS into a hamburger string.

Examples3

  1. Example 1

    Input
    1)(
    
    Expected output
    1
    
  2. Example 2

    Input
    )1(
    
    Expected output
    2
    
  3. Example 3

    Input
    (1)
    
    Expected output
    0