import
java.io.*;
import
java.util.*;
class
GFG{
static
int
MOD =
1000000007
;
static
Integer array[] = {
1
,
2
,
4
,
8
,
16
,
32
,
64
,
128
,
256
,
512
,
1024
,
2048
,
4096
};
static
Vector<Integer> MEM =
new
Vector<Integer>(
Arrays.asList(array));
static
int
mod_pow2(
int
n)
{
while
(n >= MEM.size())
MEM.add((MEM.get(
MEM.size() -
1
) *
2
) % MOD);
return
MEM.get(n);
}
static
int
inversions(
char
[] bstr)
{
int
total =
0
, zeros =
0
, questions =
0
;
int
j = bstr.length -
1
;
for
(
int
i =
0
; i < bstr.length /
2
; i++)
{
char
temp = bstr[i];
bstr[i] = bstr[j];
bstr[j] = temp;
j--;
}
for
(
char
x : bstr)
{
int
q;
if
(x ==
'1'
)
{
int
z = zeros * mod_pow2(questions);
if
(questions ==
0
)
q =
0
;
else
q = questions * mod_pow2(
questions -
1
);
total = (total + z + q) % MOD;
}
else
if
(x ==
'0'
)
{
zeros +=
1
;
}
else
{
total *=
2
;
int
z = zeros * mod_pow2(questions);
if
(questions ==
0
)
q =
0
;
else
q = questions * mod_pow2(
questions -
1
);
total = (total + z + q) % MOD;
questions +=
1
;
}
}
return
total;
}
public
static
void
main(String[] args)
{
char
S[] =
"?0?"
.toCharArray();
System.out.println(inversions(S));
}
}