#P15767. [JAG 2025 Summer Camp #2] Broken Keyboard

[JAG 2025 Summer Camp #2] Broken Keyboard

题目描述

You have a keyboard with 2525 keys. Initially, key ii (1i251 \leq i \leq 25) is mapped to the ii-th lowercase English letter, i.e., key 11 to ‘a’, key 22 to ‘b’, ..., and key 2525 to ‘y’. You also have an empty string TT.

You can perform the following two operations any number of times, in any order:

  1. Choose an integer ii (1i251 \leq i \leq 25) and a lowercase English letter cc, and change the mapping of key ii to cc. This operation costs 11.
  2. Choose an integer ii (1i251 \leq i \leq 25), and append the letter currently mapped to key ii to the end of TT. This operation costs 00.

You are given a string SS consisting of lowercase English letters. Find the minimum total cost required to make TT equal to SS.

输入格式

The input consists of a single test case in the following format.

SS

The only line contains a string SS consisting of lowercase English letters. The length of SS is between 11 and 500000500\,000, inclusive.

输出格式

Print the minimum total cost as an integer.

meatthezoo
1
zxcvbnmqwertyuiopasdfghjklzxcvbnm
2