x=[10**(205558%ord(c)%7)%9995for c in raw_input()]
print sum(n-p%n*2for p,n in zip([0]+x,x))
####
t=p=0
for r in raw_input():n=10**(205558%ord(r)%7)%9995;t+=n-2*p%n;p=n
print t
##
##
t=0
for r in raw_input():n=10**(205558%ord(r)%7)%9995;t+=n-2*t%n
print t
##
##
use List::Util 'reduce';
print reduce{$a+$b-2*$a%$b}map{10**(19&654115/ord)%1645}<>=~/./g
##
##
print reduce(lambda t,n:t+n-2*t%n,(10**(19&654115//ord(r))%1645for r in raw_input()))
##
##
p gets.chomp.bytes.map{|c|10**(205558%c%7)%9995}.reduce(0){|t,n|t+n-t%n*2}
# or:
p gets.chomp.bytes.reduce(0){|t,c|t+(n=10**(205558%c%7)%9995)-t%n*2}
##
##
# Perl:
reduce{$a+$b-$a%$b*2}map{10**(7&69303333/ord)%9995}<>=~/./g
# Python:
reduce(lambda t,n:t+n-t%n*2,(10**(7&69303333//ord(r))%1999for r in raw_input()))
##
##
t=0;t+=N-t%N*2while 0##
n=1;$.+=n/2-n%n=10**(494254%C/9)%4999while C=getc;p$.
##
##
while 0##
while N=10**(494254%getc/9)%4999/2
##
##
n=t=1;$<.bytes{|c|t+=n/2-n%n=10**(494254%c/9)%4999};p t
##
##
n=s=0;roman.bytes{|c|s+=n-2*n%n=10**(205558%c%7)%9995};s+n
##
##
s=0;roman.bytes{|c|s+=(n=10**(205558%c%7)%9995)-s%n*2};s
##
##
a=0
for e in raw_input():v=10**(84179%ord(e)%5)>>(e in'VLD');a+=v-2*a%v
print a
##
##
10**(84179%ord(e)%5)>>(e in'VLD')
##
##
1 . E.(3^77%ord)%7>>y/VLD//
##
##
hash(r+"magicstrng")%1001