class program
{
static void main(string[] args)
{
int testrecord1 = 500001;
int tempvar;
int newrecord;
tempvar = getfirstnum(testrecord1);
if (tempvar == 5)
{
newrecord = getlastnum(testrecord1);
newrecord++;
int pre = (int)math.pow(10, (getrecordlength(testrecord1) - 1));
int result = pre * 5 + newrecord;
console.writeline(result);
}
else if (tempvar == 9)
{
// like above
}
}
private static int getfirstnum(int record)
{
return int32.parse(record.tostring().substring(0, 1));
}
private static int getlastnum(int record)
{
string rcd = record.tostring();
string temp = rcd.substring(rcd.lastindexof('0'), rcd.length - rcd.lastindexof('0'));
int result = 0;
int32.tryparse(temp, out result);
return result;
}
private static int getrecordlength(int record)
{
return record.tostring().length;
}
}