#include<bits/stdc++.h>
using namespace std;
#define res register int
#define ll long long
//#define cccgift
#define lowbit(x) ((x)&-(x))
#define rep(i,l,r) for(res i=l,_r=r;i<=_r;++i)
#define per(i,r,l) for(res i=r,_l=l;i>=_l;--i)
#define mkp make_pair
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem0n(a,n) memset(a,0,n*sizeof(a[0]))
#define iter(x,v) for(res v,_p=head[x];v=ver[_p],_p;_p=nxt[_p])
#ifdef cccgift //by lqh
#define SHOW(x) cerr<<#x"="<<(x)<<endl
#else
#define SHOW(x) 0
#endif
//#define getchar()(ip1==ip2&&(ip2=(ip1=ibuf)+fread(ibuf,1,1<<21,stdin),ip1==ip2)?EOF:*ip1++)
//char ibuf[1<<21],*ip1=ibuf,*ip2=ibuf;
template<typename T>
inline void read(T &x)
{
    static char ch;bool f=1;
    for(x=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') f=0;
    for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=getchar());x=f?x:-x;
}
template<typename T>
void print(T x)
{
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
template<typename T>
inline void print(T x,char ap) {print(x);if (ap) putchar(ap);}
template<typename T>
inline void chkmax(T &x,const T &y) {x=x<y?y:x;}
template<typename T>
inline void chkmin(T &x,const T &y) {x=x<y?x:y;}
int n,cnt0,cnt1,sum0[1000001],sum1[1000001];
char s[1000001];
int main()
{
	ios::sync_with_stdio(false);srand(998244853);
	cin>>(s+1),n=strlen(s+1);
	rep(i,1,n) if(s[i]=='0') ++cnt0;
	else if(s[i]=='1') ++cnt1;
	else {
		if(cnt0>cnt1) ++cnt1,s[i]='1';
		else if(cnt1>cnt0) ++cnt0,s[i]='0';
		else {
			int now=rand()&1;
			if(!now) ++cnt0,s[i]='0';
			else ++cnt1,s[i]='1';
		}
	}
	rep(i,1,n) sum0[i]=sum0[i-1]+(s[i]=='0'),sum1[i]=sum1[i-1]+(s[i]=='1');
	int minn=0,maxx=0;puts(s+1);
	rep(i,0,n) chkmax(maxx,sum0[i]-sum1[i]),chkmin(minn,sum0[i]-sum1[i]);
	print(maxx-minn,'\n');
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do something instead of nothing and stay organized
*/ 