#include<iostream>
#include<string>
using namespace std;

int main(){
char x[200];
char Roma[7]={'I','V','X','L','C','D','M'};
int Arabia[7]={1,5,10,50,100,500,1000};
int a=0,b,ans=0,ls;
string s;
while(cin>>s){
ans=0;
a=0;
ls=s.size();
for(int i=ls-1;i>-1;i--){
for(int j=0;j<7;j++){
if(s[i]==Roma[j])b=Arabia[j];}
if(b>=a){ans+=b; a=b;}
if(b<a)ans-=b;}
cout<<ans<<endl;}}
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
string s,p;
int main()
{
    ft
    ll t,i,j,n,m=0,l,r;
    cin>>s;
    n=s.size();
    for(i=0;i<n;i++)
    {
        if((i+1)<n && s[i]==s[i+1])
        {
            cout<<(i+1)<<" "<<(i+2)<<"\n";
            return 0;
        }
        else if(((i+2)<n && s[i]==s[i+2]))
        {
            cout<<(i+1)<<" "<<(i+3)<<"\n";
            return 0;
        }
    }
    cout<<"-1 -1\n";
    return 0;
}