codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

844A.md (1464B)


      1 Source: https://codeforces.com/problemset/problem/844/A
      2 
      3 A. Diversity
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 Calculate the minimum number of characters you need to change in the string *s*, so that it contains at least *k* different letters, or print that it is impossible.
     22 
     23 String *s* consists only of lowercase Latin letters, and it is allowed to change characters only to lowercase Latin letters too.
     24 
     25 Input
     26 
     27 First line of input contains string *s*, consisting only of lowercase Latin letters (1 ≤ |*s*| ≤ 1000, |*s*| denotes the length of *s*).
     28 
     29 Second line of input contains integer *k* (1 ≤ *k* ≤ 26).
     30 
     31 Output
     32 
     33 Print single line with a minimum number of necessary changes, or the word «impossible» (without quotes) if it is impossible.
     34 
     35 Examples
     36 
     37 Input
     38 
     39 ```
     40 yandex  
     41 6
     42 ```
     43 
     44 Output
     45 
     46 ```
     47 0
     48 ```
     49 
     50 Input
     51 
     52 ```
     53 yahoo  
     54 5
     55 ```
     56 
     57 Output
     58 
     59 ```
     60 1
     61 ```
     62 
     63 Input
     64 
     65 ```
     66 google  
     67 7
     68 ```
     69 
     70 Output
     71 
     72 ```
     73 impossible
     74 ```
     75 
     76 Note
     77 
     78 In the first test case string contains 6 different letters, so we don't need to change anything.
     79 
     80 In the second test case string contains 4 different letters: {'*a*', '*h*', '*o*', '*y*'}. To get 5 different letters it is necessary to change one occurrence of '*o*' to some letter, which doesn't occur in the string, for example, {'*b*'}.
     81 
     82 In the third test case, it is impossible to make 7 different letters because the length of the string is 6.