rendered paste body#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
int main()
{
string str,res="";
int val=0,cnt=0,len,flag=true,flag1=true;
cin>>str;
len=str.length();
if(str[0]=='0') val=1;
else cnt=str[0]-'0';
for(int i=1;i<len;i++)
{
if(cnt==0&&str[i]=='0')
{
val++;
}
else if(str[i]=='0')
{
cnt--;
if(cnt==0&&i<len-1&&flag1) flag=false;
}
else if(cnt!=0) cnt+=(str[i]-'0'-1);
else
{
cnt=str[i]-'0';
val++;
flag1=false;
}
}
if(!flag) val++;
int temp=val%7;
int t=val/7;
while(val/7)
{
t=val/7;
for(int i=0;i<t;i++) printf("7");
val=t+val%7;
}
if(val!=0&&val!=1) printf("%d",val);
cout<<str;
for(int i=0;i<cnt;i++) printf("0");
system("PAUSE");
}