program z2; const w: array[1..7] of char=('I','V','X','L','C','D','M'); var d,i,n: integer; s: string; begin writeln('vvedit rim chislo'); readln(s); n:=length(s); d:=0; i:=n; if s[i]='I' then d:=d+1; if s[i]='V' then d:=d+5; if s[i]='X' then d:=d+10; if s[i]='L' then d:=d+50; if s[i]='C' then d:=d+100; if s[i]='D' then d:=d+500; if s[i]='M' then d:=d+1000; for i:=n-1 downto 1 do begin if (s[i]='I') and ((s[i+1]<>'V') and (s[i+1]<>'X')) then d:=d+1; if (s[i]='I') and ((s[i+1]='V') or (s[i+1]='X')) then d:=d-1; if s[i]='V' then d:=d+5; if (s[i]='X') and ((s[i+1]<>'L') and (s[i+1]<>'C')) then d:=d+10; if (s[i]='X') and ((s[i+1]='L') or (s[i+1]='C')) then d:=d-10; if s[i]='L' then d:=d+50; if (s[i]='C') and ((s[i+1]<>'D') and (s[i+1]<>'M')) then d:=d+100; if (s[i]='C') and ((s[i+1]='D') or (s[i+1]='M')) then d:=d-100; if s[i]='D' then d:=d+500; if s[i]='M' then d:=d+1000; end; writeln('d=',d); end.