def main():
    class int_mod:
        def __init__(self,value,mod=10**9+7):
            if value>=0:self.value=value%mod
            else:self.value=((value%mod)+mod)%mod
            self.mod=mod
        def __lt__(self,other):
            if type(other) is int:return self.value<other
            else:return self.value<other.value
        def __le__(self,other):
            if type(other) is int:return self.value<=other
            else:return self.value<other.value
        def __eq__(self,other):
            if type(other) is int:return self.value==other
            else:return self.value<other.value
        def __ne__(self,other):
            if type(other) is int:return self.value!=other
            else:return self.value<other.value
        def __gt__(self,other):
            if type(other) is int:return self.value>other
            else:return self.value<other.value
        def __ge__(self,other):
            if type(other) is int:return self.value>=other
            else:return self.value<other.value
        def __add__(self,other):
            if type(other) is int:return self.__class__(self.value+other,self.mod)
            else:return self.__class__(self.value+other.value,self.mod)
        def __radd__(self,other):
            if type(other) is int:return self.__class__(self.value+other,self.mod)
            else:return self.__class__(self.value+other.value,self.mod)
        def __sub__(self,other):
            if type(other) is int:return self.__class__(self.value-other,self.mod)
            else:return self.__class__(self.value-other.value,self.mod)
        def __rsub__(self,other):
            if type(other) is int:return self.__class__(self.value-other,self.mod)
            else:return self.__class__(self.value-other.value,self.mod)
        def __mul__(self,other):
            if type(other) is int:return self.__class__(self.value*other,self.mod)
            else:return self.__class__(self.value*other.value,self.mod)
        def __rmul__(self,other):
            if type(other) is int:return self.__class__(self.value*other,self.mod)
            else:return self.__class__(self.value*other.value,self.mod)
        def __mod__(self,other):
            if type(other) is int:return self.__class__(self.value%other,self.mod)
            else:return self.__class__(self.value%other.value,self.mod)
        def __rmod__(self,other):
            if type(other) is int:return self.__class__(self.value%other,self.mod)
            else:return self.__class__(self.value%other.value,self.mod)
        def __pow__(self,other):
            if type(other) is int:return self.__class__(pow(self.value,other,self.mod),self.mod)
            else:return self.__class__(pow(self.value,other.value,self.mod),self.mod)
        def __rpow__(self,other):
            if type(other) is int:return self.__class__(pow(self.value,other,self.mod),self.mod)
            else:return self.__class__(pow(self.value,other.value,self.mod),self.mod)
        def __floordiv__(self,other):
            if type(other) is int:return self.__class__(self.value*pow(other,self.mod-2,self.mod),self.mod)
            else:return self.__class__(self.value*pow(other.value,self.mod-2,self.mod),self.mod)
        def __rfloordiv__(self,other):
            if type(other) is int:return self.__class__(self.value*pow(other,self.mod-2,self.mod),self.mod)
            else:return self.__class__(self.value*pow(other.value,self.mod-2,self.mod),self.mod)
        def __iadd__(self,other):
            if type(other) is int:self.value=self.value+other
            else:self.value=self.value+other.value
            return self.__class__(self.value,self.mod)
        def __isub__(self,other):
            if type(other) is int:self.value=self.value-other
            else:self.value=self.value-other.value
            return self.__class__(self.value,self.mod)
        def __imul__(self,other):
            if type(other) is int:self.value=self.value*other
            else:self.value=self.value*other.value
            return self.__class__(self.value,self.mod)
        def __imod__(self,other):
            if type(other) is int:self.value=self.value%other
            else:self.value=self.value%other.value
            return self.__class__(self.value,self.mod)
        def __ipow__(self,other):
            if type(other) is int:self.value=pow(self.value,other,self.mod)
            else:self.value=pow(self.value,other.value,self.mod)
            return self.__class__(self.value,self.mod)
        def __ifloordiv__(self,other):
            if type(other) is int:self.value=self.value*pow(other,self.mod-2,self.mod)
            else:self.value=self.value*pow(other.value,self.mod-2,self.mod)
            return self.__class__(self.value,self.mod)
        def __neg__(self):return self.__class__(-self.value,self.mod)
        def __pos__(self):return self.__class__(+self.value,self.mod)
        def __invert__(self):return self.__class__(~self.value,self.mod)
    
    n=input()
    o,h=int_mod(1),int_mod(2)
    for i in range(1,len(n)):
        if n[i]=="1":
            o=3*o+h
            h*=2
        else:
            o*=3
    print((o+h).value)
main()

Measured memory_bytes: 3436