a=input()
s=0
b={"I":1,"V":5,"X":10,"L":50,"C":100,"D":500,"M":1000}
c=[i for i in a]
if len(c)%2==0:
for j in range(0,len(c)//2+1,2):
if b[c[j]]>=b[c[j+1]]:
s=s+abs(b[c[j]]+b[c[j+1]])
else:
s=s+abs(b[c[j]]-b[c[j+1]])
else:
d=c[0]
del(c[0])
for j in range(0,(len(c)//2)+1,2):
s=s+abs(b[c[j]]-b[c[j+1]])
s=s+b[d]
print(s)
NOTE: IF U HAVE ANY DOUBTS YOU CAN ASK IN COMMENT SECTION.
No comments:
Post a Comment