A. Diversity
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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.

String s consists only of lowercase Latin letters, and it is allowed to change characters only to lowercase Latin letters too.

Input

First line of input contains string s, consisting only of lowercase Latin letters (1 ≤ |s| ≤ 1000, |s| denotes the length of s).

Second line of input contains integer k (1 ≤ k ≤ 26).

Output

Print single line with a minimum number of necessary changes, or the word «impossible» (without quotes) if it is impossible.

Examples
input
yandex
6
output
0
input
yahoo
5
output
1
input
google
7
output
impossible
#include <iostream>
#include<string>
#include<set>
#include<algorithm>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
//set<int>ff;
int main(int argc, char** argv) {
set<int>ff;
string s;
int k;
cin>>s;
cin>>k;
int len=s.size() ; for(int i=;i<len;i++)
{
ff.insert(s[i]);
}
if(len<k)
printf("impossible\n");
else
{
int w=ff.size();
if(w>=k)
printf("0\n");
else
printf("%d\n",k-w);
}
return ;
}

最新文章

  1. linux下mono的安装与卸载
  2. AJAX-初学AJAX本地环境配置
  3. Sublime Text 2 中文 GBK 规范的配置 暨 解决中文乱码问题 简述
  4. eclipse错误:Unable to read workbench state. Workbench UI layout will be reset.XML document structures
  5. JavaScript 类
  6. 设计模式(六):Singleton 单件模式 -- 创建型模式
  7. Redis集群明细文档(转)
  8. javascript深入理解js闭包(个人理解,大神勿喷)
  9. 连续多个git提交发生了冲突时
  10. mysql修改数据库名
  11. 修改CentOS6.5默认主机名(root下操作)
  12. 【原创】Linux基础之常用命令
  13. angular bootstrap timepicker TypeError: Cannot set property &#39;$render&#39; of undefined
  14. Spring MVC中@JsonView的使用
  15. 在Mysql中查询两个时间段的差,可以是秒,天,星期,月份,年...
  16. shiroWeb项目-认证及MD5认证信息在页面显示(十)
  17. CSS3 Flex布局整理(三)-项目属性
  18. [Solution] The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path
  19. 添加网络ADB的方法(含以太网和无线)
  20. Eclipse中的特殊注释:TODO、XXX、FIXME

热门文章

  1. e.preventdefault() 别滥用
  2. python while循环与for循环
  3. 通过ip地址访问同一局域网下已经启动的angular项目
  4. Ubuntu安装MySQL及使用Xshell连接MySQL出现的问题(2003-Can&#39;t connect to MySql server及1045错误)
  5. maven入门2
  6. 云计算之KVM虚拟化实战
  7. Javascript简单特效及摘要
  8. JAVAOOP继承
  9. 带密匙的php加密解密示例分享
  10. 图解HTTP总结(6)——HTTP首部