[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

[<EntryPoint>]
let main _ =
    let ss = (read string).ToCharArray()
    Array.countBy id ss
    |> Array.map snd
    |> fun xs ->
        if Array.length xs = 1
        then 0
        else Array.min xs
    |> fun x -> printfn "%i" (x * 2)
    0