#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main ()
{
	int c;
	cin >> c;
	int pot;
	cin >> pot;
	int p=0;
	int znam[11];
	int a=c;
	while (a!=0)
	{
		znam[p]=a%10;
		a/=10;
		p++;
	}
	for (int i=0; i<p; i--)
	{
		if (pot==0)
			break;
		if (znam[pot-1]%10<5)
			c-=znam[pot-1]*(pow(10.,(double)pot-1));
		else 
			c+=(10-znam[pot-1])*(pow(10.,(double)pot-1));
		pot--;
	}
	cout << c;
	//system("pause");
	return 0;
}
		
		
