/*
Online Java - IDE, Code Editor, Compiler

Online Java is a quick and easy tool that helps you to build, compile, test your programs online.
*/
//VERSION 3c
//return statements again bizarrely do not stop execution.
//Also removed system.exit(0) and set flag to control code flow.
//This code takes logical concepts from Version1 and Version2
//but written from scratch.
//But much easier to the eye, but also seems just as long!

//In VERSION1 and VERSION2, accessing number1 and number2 with substring
//In this example  remainingPortionFirstNumber = Integer.toString(number1);
//so it is not sufficient to use int since it will limit length of the number.

//also this is more closer to the first principles used in addition
//it can be seen henceforth I reduced the final test points
//the code is much more tider, better variable names
//So I will explain most logic at variable declaration.
//using same test casee.
//Most importantly, it is 100% recursion based.

//I envisage I need to incorporate this into Version1 and Version2 to ensure
//it removes iteration... and also remove do while loop

import java.util.*;

public class Main
{
    //these variables manage the StopClock
    static long startTime;
    static long endTime;
    static boolean running;
    static long elapsed;
    
    static long lastDigitNumber; //this performs %10 on remainingPortion
    
    // this is the (initial number /10) to remove lastDigitNumber
    static String remainingPortion;
    
    static boolean finishedUniformMSD; //it has finished addition of the most MSD
    //common at same position on number1 and number2
    
    //once it has determined grandTotal (remainingPortion is empty)
    static boolean finishedExecution;

    //either 1 or 0 as in real world
    static long carryForward;
    
    //total of the digits
    static long total;
   
    //remainingPortionFirstNumber or remainingPortionSecondNumber 
    //are changed to this variable
    //once either remainingPortionSecondNumber==0 
    //or remainingPortionFirstNumber==0
    //i.e it is processing the left non uniform MSD
    //For instance the   remainingPortionFirstNumber= 7 is assigned to number
    //76      number1
    //+8      number2
    static String number;
    
    static String grandTotal=""; 
    // as you would expect to see in equals
    //section when performing calculation
    //   556 
    //  +733
    //  ------
    //  1289
     // ------
     
    //it keeps backupTotal since it might have filled grandTotal
    //above such as   289 (taking lastDigitTotal=2)  
    //and expecting another.. But if there is not another number,
    //it has to store the backupTotaltotal = 12  to give 1289
    static String backupTotal;
   
    //likewise it stores backupGrandTotal since above grandTotal
    //would be 289 and if it realises 
    //remainingPortionFirstNumber and remainingPortionSecondNumber are 0
    //it would attempt grandTotal = total + grandTotal    = 12289
    //instead it has to re-instate backupGrandTotal = 89
    //perform grandTotal= String.valueOf(backupTotal) + backupGrandTotal  = 12 89
    static String backupGrandTotal;
   
    //it starts as Integer conversion from String number1/number2
    //progressively gets smaller
    static String remainingPortionFirstNumber;
    static String remainingPortionSecondNumber;
   
    //this will be %10 of their respective remainingPortionXXXX
    static long lastDigitFirstNumber;
    static long lastDigitSecondNumber;
    static String lastDigitNumberString;
    
    //total always two digits wide. This will get least MSD (total%10)
    static long lastDigitTotal;
   
   //logic generated via AI.
   //used for stop clock function
    public static void start() 
    {
        Main.startTime = System.nanoTime();
        Main.running = true;
    }

    public static void stop() 
    {
        Main.endTime = System.nanoTime();
        Main.running = false;
    }

    public static long getElapsedTime() 
    {
        if (running) 
        {
            elapsed = System.nanoTime() - startTime;
        } 
        else 
        {
            elapsed = endTime - startTime;
        }
        return elapsed;
    }

    public static double getElapsedTimeInSeconds() 
    {
        return getElapsedTime() / 1_000_000_000.0;
    }    
   
    public static void main(String[] args) 
    {
        System.out.println("Welcome to Online IDE!! Happy Coding :)");
        
        //extensive test cases.
        //All tested with flag finishedExecution in code
        //also used return statements (fail to function)
        //removed system.exit(0);
        
        //***PASS****  - 100*** via final test 0,1,3,4,7,8,9,10,11,17,18,21 (v3,v3a)
        //***PASS****  - 100*** via final test  (v3c) 0,1,3,4,7,8,9,10,19 (v3c)
        //String number2="99";
        //String number1= "1";
        
        //***PASS**1764*** via final test 0,1,2,3,4,5,6 (v3,v3a)
        //***PASS**1764*** via final test 0,1,3,4,5,6,7 (v3c)
        //String number2="993";
        //String number1="771";
        
        //***PASS**1764*** via final test via final test 0,1,2,3,4,5,6 (v3,v3a)
        //***PASS**1764*** via final test via final test 0,1,3,5,6,7,19 (v3c)
        //String number2="243";
        //String number1="541";
        
        //PASS*****160****** - via final test 0,1,3,4,5,7,8,9,14,21 (v3,v3a)
        //***PASS**1764*** via final test via final test 0,1,3,4,5,7,8,9,10,19 (v3c)
        //String number2 = "136";
        //String number1 =  "24";
        
        //PASS******846370032454542****** via final test 0,3,4,7,8,9,10,12,13,17,18,21 (v3,v3a)
        //PASS******846370032454542****** via final test 0,1,3,4,7,8,9,11,12,19(v3c)
        //String number2 = "846369999999999";
        //String number1 =        "32454543";
        
        //PASS****82160**** via final test 0,1,3,4,5,7,8,9,14,15,21 (v3,v3a)
        //PASS****82160**** via final test 0,1,3,4,5,7,8,9,12,19 (v3c)
        //String number2 = "81636";   
        //String number1 =   "524";
        
        //PASS******* - 400219  via final test 0,1,3,4,5,7,8,9,10,11,12,17,18,21 (v3,v3a)
        //PASS******* - 400219  via final test 0,1,3,4,5,7,8,9,10,11,19 (v3c)
        //String number2 = "399627";   
        //String number1 =    "592";
        
        //pass********* - 400019 via final test 0,1,3,4,5,7,8,9,10,11,12,17,18,21 (v3,v3a)
        //pass********* - 400019 via final test 0,1,3,4,5,7,8,9,10,11,19 (v3c)
        //String number2 = "399947";   
        //String number1 =     "72";
        
        //PASS***4962****** getting via final test 0,1,3,4,5,7,8,9,14,21 (v3,v3a)
        //PASS***4962****** getting via final test 0,1,3,4,5,7,8,9,10,19 (v3c)
        //String number2 =   "3970";   
        //String number1 =    "992";
        
        //PASS******  562  via final test 0,1,2,3,4,5,6 (v3, v3a)
        //PASS***4962****** getting via final test 0,1,3,4,5,6,7 (v3c)
        //String number1 =   "370";   
        //String number2 =   "192";
        
        //PASS**** - 1000  via final test 0,1,4,7,8,9,10,11,12,21 (v3, v3a)
        //PASS***4962****** getting via final test 0,1,3,4,7,8,9,10,11,19 (v3c)
        //String number2 =   "999";   
        //String number1 =     "1";
        
        //PASS*****  1998 via final test
        //PASS***4962****** getting via final test 0,1,3,4,6,7 (v3c)
        //String number1 =   "999";   
        //String number2 =   "999";
        
        //PASS ******* 1098 via final test 0,2,3,4,7,8,9,10,11,17,18,21 (v3, v3a)
        //PASS ******* 1098 via final test 0,2,3,4,7,8,9,10,19(v3c)
        //String number1 =   "999";   
        //String number2 =    "99";
        
        //***PASS***108 via final test 0,2,3,4,7,8,9,10,11,18,19,21 (v3, v3a)
        //***PASS***108 via final test 0,2,3,4,7,8,9,10,19 (v3c)
        //String number1 =   "99";   
        //String number2 =   "9";
    
         //***PASS**** 1400019  via final test 0,1,3,4,5,7,8,9,10,12,13,21 (v3, v3a)
         //***PASS***108 via final test 0,1,3,4,7,8,9,11,12,19 (v3c)
         //String number2 = "1399947";   
         //String number1 =      "72";
         
        //***PASS****5210*** via final test 0,1,3,4,7,8,9,14,21 (v3, v3a)
        //***PASS****5210*** via final test 0,1,3,4,7,8,9,10,19 (v3c)
        //String number2 = "4666";
        //String number1 =  "544";
        
        //***PASS***711**** via final test 0,1,3,4,7,8,9,14,21 (v3, v3a)
        //***PASS***711**** via final test 0,1,3,4,7,8,9,10,19 (v3c) 
        //String number2 =  "652";
        //String number1 =   "59";
        
        //PASS****1390219 ***** via final test 0,3,4,5,7,8,9,10,12,13,17,18,21 (v3, v3a)
        //PASS****1390219 ***** via final test 0,1,3,4,5,7,8,9,11,12,19 (v3c)
        //String number2 = "1389627";   
        //String number1 =     "592";        

        //PASS***********22023**** via final test 0,2,3,4,7,8,9,10,12,13,17,18,21 (v3, v3a)
        //PASS***********22023**** via final test (v3c) 0,2,3,4,7,8,9,11,12,19
        //String number1 = "21999";   
        //String number2 =     "24";
        
        //PASS****2*******  via final test 0,1,2,3,5,6 (v3, v3a)
        //PASS****2*******  via final test 0,1,3,5,6 (v3c)
        //String number1 = "1";   
        //String number2 = "1";
        
        //PASS***10********  via final test 0,1,2,4,6 (v3, v3a)
        //PASS***10********  via final test 0,1,3,4,6 (v3c)
        //String number1 = "1";   
        //String number2 = "9";
        
        //PASS***95759******** via final test 0,2,3,5 (v3, v3a)
        //PASS***95759******** via final test 0,2,3,5,7,8,9,19 (v3c)
        //String number1 = "95427"    
        //String number2 =   "332";
        
        //PASS*****9719******   via final test 0,2,3,4,5,7,8,9,14,15,21 (v3, v3a)
        //PASS*****9719******   via final test 0,2,3,4,5,7,8,9,12,19 (v3c)
        //String number1 = "9647";   
        //String number2 =   "72";
        
        //PASS****100119*******   via  final test 0,2,3,4,5,7,8,9,10,11,12,17,18,21 (v3, v3a)
        //PASS****100119*******   via  final test 0,2,3,4,5,7,8,9,11,19 (v3c)
        //String number1 = "99647";   
        //String number2 =   "472";
        
        //**PASS** 10009 via  final test 0,2,3,4,5,7,8,9,10,11,12,17,18,21 (v3, v3a)
         //**PASS** 10009 via  final test 0,2,3,4,5,7,8,9,10,11,19 (v3c)
        //String number1 ="9947"; 
        //String number2 = "62";
        
        //PASS via  final test 0,2,3,4,7,8,9,10,12,13,17,18,21 (v3, v3a)
        //PASS via  final test 0,2,3,4,7,8,9,10,11,12,19 (v3c)
        //***PASS  22023
        //String number1 = "21999";   
        //String number2 =     "24";
        
         //***PASS***108 via final test 0,2,3,4,7,8,9,10,11,18,19,21 (v3, v3a)
         //***PASS***108 via final test 0,2,3,4,7,8,9,10,19 (v3c)
        //String number1 = "99";   
        //String number2 =  "9";
        
        //PASS getting 1000  via final test 0,2,3,4,7,8,9,10,11,12,17,18,21 (v3, v3a)
        //PASS getting 1000  via final test 0,2,3,4,7,8,9,10,19  (v3c)
        //String number1 = "999";
        //String number2 = "1";
        
        //PASS via final test 0,2,3,5,7,8,9,14,15,21 (v3, v3a)
        //PASS via final test 0,2,3,5,7,8,9,12,19 (v3c)
        //String number1 = "888";
        //String number2 = "1";
        
        //FAIL NumberFormatException  remainingPortionFirstNumber=Long.valueOf(number1); (v3,v3a)
        //PASS via final test 0,1,3,4,6,7,19   (v3c)
        //String number1 = "99999999999999999999999999999999999999999999999999999999";
        //String number2 = "32423543534543532423432423432494355443534532235324324333";
       
       //shortened the numbers same outcome 
       //FAIL NumberFormatException  remainingPortionFirstNumber=Long.valueOf(number1);  (v3,v3a)
       //PASS via final test 0,3,4,2,7,8,9,11,19   (v3c)
        //String number1 = "99999999999999999999999999999999999";
        //String number2 = "32423543534543532";
        
        //shortened the numbers same outcome 
        //FAIL NumberFormatException  remainingPortionFirstNumber=Long.valueOf(number1)  (v3, v3a)
        //PASS via final test 0,3,4,2,7,8,9,11,19   (v3c)
        //String number1 = "321326263232722172323121232212212212";
        //String number2 = "32423543534543531";
        
        //shortened the numbers, any longer than this and program will render 
        //FAIL NumberFormatException  remainingPortionFirstNumber=Long.valueOf(number1);
        //***PASS*** 1845561698584545666  via final test 0,1,2,3,4,5,6 (v3,v3a)
        //***PASS*** 1845561698584545666  via final test 0,1,3,4,5,6,7,19 (v3c)
        //String number1 = "921326263239897898";
        //String number2 = "924235435344647768";
        
        //**************INTRODUCING FEW EXTRA TEST CASES
        
        //***PASS   1000000  via final test 0,2,3,4,7,8,9,10,11,12,17,18,21 (v3,v3a)
        //***PASS   1000000  via final test 0,2,3,4,7,8,9,10,11,19 (v3c)
        //String number1 = "999999";
        //String number2 = "1";
        
        //****PASS  10001424201998***  via final test 0,2,3,4,5,7,8,9,11,12,17,18,21 (v3,v3a)
        //****PASS  10001424201998***  via final test 0,2,3,4,7,8,9,10,11,19 (v3c)
        //String number1 = "9999990767676";
        //String number2 = "1433434322";
        
        //****PASS  giving 9999990767677***  NOW FIXED via final test 0,2,3,5,7,8,9,14,15,21 (v3,v3a)
        //****PASS  giving 9999990767677***  final test 0,2,3,5,7,8,9,12,19 (v3c)
        //similar issues below previously
        //String number1 = "9999990767676";
        //String number2 = "1";
        
        //****PASS  giving 7899990767677***  NOW FIXED via final test 0,2,3,5,7,8,9,14,15,21 (v3,v3a)
        //****PASS  giving 7899990767677***  via final test 0,2,3,5,7,8,9,12,19 (v3c)
        //String number1 = "7899990767676";
        //String number2 = "1";
        
        //PASS  ***78990767677****   via final test 0,2,3,5,7,8,9,14,15,21 (v3,v3a)
        //PASS  ***78990767677****   via final test 0,2,3,5,7,8,9,12,19 (v3c)
        //String number1 = "78990767676";
        //String number2 = "1";
        
        //****PASS  giving 97653*** via final test 0,2,5,7,8,9,14,15,21 (v3,v3a)
        //****PASS  giving 97653*** via final test 0,2,5,7,8,9,12,19 (v3,v3c)
        //String number1 = "97652";
        //String number2 = "1";
        
        //Test case exclusive to v3c (3000 digits wide)
        //String number1 = "555418988416629253420718496854693264446474315507822060564627820358402026037619780575719162769259233240677357230285005574138788049820951536266943641343868373054036422306040612520405178100180293101998852886175892595497014909238920567104007718236270873344927275067759361986159805092101349760180463561804291165677915570777010626278787600378321378528047863827661820193955762460980802839063358710941685295302615716858918474136247281407287902016435261032949712160632909405566717210543005928647366009685704248278514232489765740842990292328100313874234122350835427637430570622752281657588314883417933780097848579181168582541706830021455847487835866156184681077571144849322487612026435858373496520076262818794628906205136750568571231972727888696631517785393735220736899567696283261966821668758337251128415123175574822732701514218363578125114334610277400914683579917932926355947086615477669433272783159334591442120394876307977131708213500428710414254996105111008334105824641062126913743510029384032576024311535794162494454365573081048783349376009605991745760367857223801163391884749828111118568782126637654265393555367637453157902650200901485099564543885819595829443417667457266939276277542402272872787758465939757592666549608042845808267552227165769896438612600524989518089308306901630302969581715978295414389377950694590497520013571493468663115508104375951193039502068203311605630573624649547711033264419670249864359411748936248287060181569152779817317083323683347772054014181664534121665664284049704124025589636942060083254891220283948871204245947340029983736760279945585276084618422954611563618966204146231384884166616470176301523477159011045211234647169631835618060644746452880717528936963350841013172204549326187682185633834405693947974284268377142737918235037347187031628788509972430926364446070331053179589876387479745809048456686428402150358329392645949354998895711510215383600507233642800387618664165402394173141617754309370825658824690920012557689369158089755389892989060020902128085844240284431912772652499318834073283889577791317785763868993714436215719671312776891246815229708778186136125640034995358027281475984261427286561684463667353282809628692514817508740664706989481492450494095219534414355149362123381260357058994601712437069183054903151982922039123229845992802458511251246175064376257810830220967512798974674114150391028958423016789737231824391305199716541594292475603550248435334846584807683005537502969888511034884560894449184484384662679574368704998482999646717457123180680676271918406563566183815385124938987162039289790234249860579530475233249201555890111600802357765945476399459875412226244008482291879648261073520331418780025823322313400354096680831133586920411305127357706154314807056522304267060033761635805851616087521596024455119928634495176868882939659321878601090783146626173890080797308176965614442514230933843947966834728017013072090440872156926708232367126650828171096694215817337609751687964584640980343703643858781412493074886419371908976020284644880192576646947745990402";
        //String number2 = "756541625661614044115454171719166500882450810184545431163638632431188800305523852577696972185206860082332659373323544231768753086901937545839874964392551608328911367467724031781071714939915243895631026414474123860908079432963469686612343353299274073505574026486262928001346865957839108753979515824625094526513421684676718860425880212727636689456465957249035129663980423286072565471949888364373216379646410386642142871506714085403264778960096932009245145862760321892446484514613246510444370837070901673756455684783828619422395123205355035965589598004918493114330475698767060185225490734181883323802548020374480176871569382691903295475123930542732273364749053450141776414160074462826977673380396362682578483705391707192054637328836338069616068819040078722876217092595444062950680108366975901657688319068513219990744558109302252536784959170745382338177835335507642363252680156395422154468114037526588043990567327682829263930786632864923375331368323608236273191854756542102421954234736724794804080223064404254836321190450572494448765878012634932290229530695269098195021917035889595480728881466643208036045674581205072378154817595996279395108506646074598883815357061639124475721689594850126890599999158533335693684186100322149763568421397136328699220676881748557473689956946996283196069807910723572373651602754373587381862870527280594131047649830884793889925901230636808223223400522218378644240476006026507214760243516734831526536343793086005216056808688974908551881750668826002906898719131715374701409613273852688077860853113025666123290103220195384247330868448359654136068090692115854174041454821567647046318693093639486999493848250083956904491819197153806859423712627314466042919417744469805246409738558754313714018822980283287620554542354105969989695923194313495762672101960118359336240532460426055913779834462492141712640823143668036047353959342618725653686061365575658997491076877232251065233564548176583029965883325791368775168294340034827017679829673354372179271988129497913094987502720673534671579258702510969035709077291094100927924637189073766304330420992911620396424469061975694777182832478457210112076237015744490366790709830514241570144953625149283587850771509595304277035920155040615999676155141649024379488043338938179155486613408477476905221125342107399629257902131537661462459676812894962056222290225529645556371398460787333198494932912022605177867660595351953585360335306270319926029242141022171441470095292774167222399664933414148358544184964777368448619893960081489100285778753403629388826674419585283594850348859466839806418949653087852688839726177442485291153654031470425106478651120391959867565079279060021607923515549190716025552310924167063797685632758587008491555428200076908362678039532206830324971426947436157879338853252081217222380585946131981542651586362462580230443484188707742748326380950469018738187791963057676660378199583329667202171795740018694236564853788949080945665681164741895915826527434253381659021954044054838088454657675024670905286964699504006068930248357840";
        
        //Test case exclusive to v3c (2000 digits wide)
        //String number1 = "50369128439363588387346673857897355109059928773870791594365148198336121593646789032640854845440465027802089020523480252552230973185584281846346070648233870028824356006046715217033572798625540020371152312807972258254657479785629808676896483444038763322497861934820553564222099042477558114459281201202120557354984154121520644345709748502995038611484551330553700742437274642723436735441377421851141379164403168360011527950839387119249861879647628477691771122052206222709982485444642423705737762784229003611053707021455358869036124856929571740154664959054647606416172403092590516377970805750402802490061719298208377120447378283886620796356617703621897136148487877340571175758907864653505009290404406176221467891906849788714836023642546061447091336130587297927071216947104695493698205667468390970861341922239886551644160445306195217203977063461463916461731981142431453075285329539293670955103327515109085289390333233915691793205829324214670401959902771951848271874225712903028866578639255149829371647521041010708107091505525547751617382394833564493072523024329788238277124850068384699971761754689280207263212191971325201489984082640153113744946473713873770291130970426446608030444142089831741506454905009789948560166297073502913224288673502048380593800069803458509647687439401693573056904173289282843417469181837717370952315054405582049964675721725919617396580886947183390024889668082065172819140445832158755436647309308888005024716529995125717725739272135892914256313456593842049095926406809185573925399547729014184662275268640557000387108414568661733304889529954855655441582885565439131175014424982545256039987446635915990898048011679057204392477416573084323666681972059748546108534024411581763865323305305241873150985702427346570109139109817344003686551722945222604936889795267343415756743265789266911682241398729724549124106027527014358170588992597669671360879297174486817718194871287566417864150600907778708923339007018986913171250037638619935356930858101359057051795316506466678978067631869256794823";
        //String number2 = "16226123504000191138171164935393868461688003925920490740323057119400073538603607788607908324876057897342732721016052683113183613366194206326644187538440950207384237377043198790193147449085705812062346185668296417033851884824766462754169438401669914567694107896707621989971139800357030432618064211383696416252203000310862444030779411763270663439567276429913680890951884962372974792092351670298085194798794365230938931317200473515640544714395924035007757570622095196848606518890750142033311165311728351960561250616541933329958585183658526617284654578874967711754970344419472462049898719489854977413529698511400484075132400155638801206627874588618055444063406543653704167022260821236081499557066438231587159152862395037358792720951657388062978445021770313169559929468226785668730184893015021268405935891115232451034543313508195172499760197209616575299524988450622869152912778716454300899648079576360382516642022467500972768718361037964797534403038598793292555396098615493188900679856800993800447817519700728607176013851597172866525588189562573031338200532311804520130068965663654952869040118918072811342693217617801122850293471890896263870498132755266221725425507008347128673265935916459545975966288315762505896715350693093005789506562474016038961855312221905086831440041070054442866794862305687905673721856309487208428950321554771817377696152059934013609986267978013108914705021786811284113077959378579554959157616802342199655105506512729034646039660960070346328218369827035145273596942782607569593807545196128751862484394830171108228239867392985791341422389926579576845367713576210102835412253420584846257556788650532835782542225040387794431309417602020983022302654286276294964313704682488681781152649061709029755106749077285180737569451529442994109065342949624677980611351365664623160034275363816957166589550051478504986403627633081046632064375791881206944427581143571759169687167394448080636054361627619397431438036654775431822760286345166488257346466119219741505620547648151768408376912794227192845";
        
        //Test case exclusive to v3c (1000 digits wide)
        //stackOverflow (this is most likely due to level of intermittent System.out.println)
        //will re-test this again in v3d
        //String number1 = "6540408803676551856145754179494952031641751128938027081594109202941756393226600543442882752269695699314042509372562558035130155201235804416978442814716066633331684701309041944005933247492197161537430092964009925405404898093526197642656517976584402351120676894496344261101405074960742354825237877067766853289546572193680145918374055798302988968834940477270175023190608474863156041621058818536387660102334688446945999090446482095744628218001727163921152732660767345773459639050652506355208586088750291880562756699402838634781859401130188701054500767361258391309050251719335317483963696204779416453856290531735715655327874145804266814260091376933819405380392275021015874472850932801040745170331303362597842318250992266261656408965264590813305010031071484186291362501565229382649717826676879079939023169464056918062405311960125664527591607096298568512328375412475040177207461557189616645485993869628393441369935104158144300929321447102562449799751532705610050434477191394853945579500622980227327294889425";
        //String number2 = "7593410793529320655807929208968270551535998505826704128970255423500360626507399748509853638797593338172131057078788529171487853931504412968660404836649088427154304981895602194007150101379636457587140031561726688476488599318208789255159152480106746206821041892814777363743524485987173606432564541793846769177056985798791440794492879614900804561622296552728633957252870806248141495295602565231667897713857384870031236414400670135477542145666281451320150715222208568234708115229889236307546686999960233822661299424227773832094687753287534950038257904558567149723965050532095329485217238575977582602236472383796411931990419506054663685156533708137600219118043146561240650549589756433199762237109639228161373477310197951132352820338503495697742577273196357685668607065398283252316052259220851856058011180454199637959948127379191174169086619150340599040929800077491194617808338639416446912856825955836566616434433183609692372490302986649736278056162756355200464472501738106748874515140997303553131579323045";
        
        //Test case exclusive to v3c (500 digits wide)
        //PASS via final test 0,1,3,4,5,6,7,19
        //String number1="44588794920156385020618989453516873402296213115430211273094495832773839994702700783211129203106433325264791479271736181009102484754153124328608907010185380453083084532699801692851385831071893495634373144104458898131292472173805827793111253789485161356772309347962529032470629220129074523117488203777052933394794661551754680233794234810437526349590153066728560316382985053308668436052262732234637545246605298268753647870088457704353600047981319051624818279858556391491845895622423415243134608715949035";
        //String number2="68725821128271887743673605729732681037343324154493346721890730262336075679999883656417766690848092791710847369632801131693688281945601319627424906000846572759971516657232384729839375931380951183873753928668449616756468479706521208197997973361117584200186390298788232006305201120836792698054054013349520267904168958754128591755065414086294094559058977058792769350606027102199414759633780888520510477258925236600497611945800711510783751645946149197832245544146125236437444772564688256505434965294501933";
        
        //can be used to fill random numbers, however it has failed to fill properly
        /*
        Random rand = new Random(10);
        
        for (long f=0; f<1; f++)
        {
            number1 = number1 + Integer.toString(rand.nextInt());
            number2 = number2 + Integer.toString(rand.nextInt());
        }
        */
        
        //starts the clock
        start();
        System.out.println(number1 + "+" + number2 + "= " + addition(number, number1, number2));
        System.out.println(number1 + "+" + number2 + "= " + grandTotal);
        
        //stops the clock
        stop();
        System.out.println("Elapsed time in seconds: " + getElapsedTimeInSeconds());
       
    }
   
    public static String addition (String number, String number1, String number2)
    {
        System.out.println("final test 0");
        //gets the entire number into long variable
        remainingPortionFirstNumber=number1;
        remainingPortionSecondNumber=number2;
        
        //it assumes there are more
        //MSD available in remainingPortionSecondNumber
        //so remainingPortion gets value of remainingPortionSecondNumber
        //the generic variable number is also now value of number2 
        if (remainingPortionFirstNumber.isEmpty() && !finishedUniformMSD)
        {
            System.out.println("final test 1");
            System.out.println("FORCE 1");
            //generic variables are set on remaining part of number2
               
            remainingPortion=remainingPortionSecondNumber;
            number=number2;   //it assigns the other number to give correct logic
            finishedUniformMSD = true;
        }
        
        //it assumes there are more
        //MSD available in remainingPortionFirstNumber
        //so remainingPortion gets value of remainingPortionFirstNumber
        //the generic variable number is also now value of number1
        if (remainingPortionSecondNumber.isEmpty() && !finishedUniformMSD)
        {
            System.out.println("final test 2");
            System.out.println("FORCE ");
            remainingPortion=remainingPortionFirstNumber;
            number=number1;  //it assigns the other number to give correct logic
            finishedUniformMSD = true;
            System.out.println("WHAT ISP: " + remainingPortionFirstNumber);
            System.out.println(grandTotal);
        }
    //Note in practice both varies can be 0.
    //above if useful until situation arises (i.e from point finishedUniformMSD=true)
    //to remainingPortionFirstNumber && remainingPortionSecondNumber = 0 (last calculation)
            
    //in meantime it is focussing on getting to the finishedUniformMSD, hence code below.
    //it starts calculation   MSD<=LSD
            
        if (!finishedUniformMSD)
        {
            System.out.println("final test 3");
            System.out.println("this is when the code flows");
                
            System.out.println(remainingPortionFirstNumber);
            System.out.println(remainingPortionSecondNumber);
           
            //remainingPortionFirstNumber is equal to number1
            //remainingPortionSecondNumber is equal to number2
            
            lastDigitFirstNumber = Long.valueOf(number1.substring(number1.length()-1));
            System.out.println("This is last digit first number: " +lastDigitFirstNumber);
                
            lastDigitSecondNumber = Long.valueOf(number2.substring(number2.length()-1));
            System.out.println("This is last digit first number: " +lastDigitSecondNumber);
                
            //adds digits naturally
            //this is my first addition. It is not violated anything in the challenge
            //Since this is only technique to perform calculation. Challenge is not asking
            //re-invent addition operator.
            total = lastDigitFirstNumber + lastDigitSecondNumber;
           
            System.out.println(lastDigitFirstNumber +  "+" + lastDigitSecondNumber + "="+total);
            System.out.println("GRAND SO FAR1: " + grandTotal);
            System.out.println(total);
                
            //moves across one digit like in real life addition.
            //equivalent to discarding last digit
            number1 = number1.substring(0,(number1.length()-1));
            number2 = number2.substring(0,(number2.length()-1));
         
            //ie if total+carryForward is 10-18 and not finishedExecution
            if (total+carryForward>=10 && !finishedExecution)
            {
                System.out.println("final test 4");
                System.out.println("OVER");
                System.out.println("WHAT IS LAST DIGIT TOTAL: " + lastDigitTotal);
                    
                //keeps backup as explained in variable declaration area
                backupTotal=Long.toString(total+carryForward);
                backupGrandTotal = grandTotal;
                    
                //stores the total + carryForward
                //note for first execution, carryForward it inherits is 0
                total = total + carryForward;
                    
                //as real life, it uses the 2nd digit to store in grandTotal
                lastDigitTotal = total%10;
                    
                //it is lastDigitTotal stored as MSD each time
                grandTotal = lastDigitTotal + grandTotal;
                    
                //carryForward set since total = 10+
                carryForward=1;
               
                System.out.println("***GRAND SO FAR: " + grandTotal);
                System.out.println("backup GRAND SO FAR: " + backupGrandTotal);
                System.out.println("backup total SO FAR: " + backupTotal);
                    
                //recursive call again.
                //Note variable number is not in any other logic until
                //finishedUniformMSD=true;
                    
                addition(number, number1, number2);
            }  //end of if total 10-18
                
            //total + carryForward <10
            if (total+carryForward<10 && !finishedExecution)
            {
                System.out.println("final test 5");
                System.out.println("UNDER");
                    
                backupTotal=Long.toString(total+carryForward);
                backupGrandTotal = grandTotal;
                total= total + carryForward;
                    
                lastDigitTotal = total%10;
                System.out.println("WHAT IS TOTAL:");
                grandTotal = lastDigitTotal + grandTotal;
                carryForward=0;
               
                System.out.println("GRAND SO FAR: " + grandTotal);
                System.out.println("backup GRAND SO FAR: " + backupGrandTotal);
                System.out.println("backup total SO FAR: " + backupTotal);
               
                addition(number, number1, number2);
                }  //end if total +carryForward<10
                
            }  //end of if (!finishedUniformMSD)
            
            //System.out.println("NOT HERE1");
            
            //means both numbers were uniform length and reached MSD
            //it has to rely on the backup variables.
            //see explanation in declaration
            if (number1.isEmpty() && number2.isEmpty())
            {
                System.out.println("final test 6");
                System.out.println("backuptotal: " + backupTotal);
                System.out.println("backupGrandTotal: " + backupGrandTotal);
                System.out.println("grandTotal: " + grandTotal);
           
                grandTotal= String.valueOf(backupTotal) + backupGrandTotal;
           
                System.out.println("uniform numbers finished execution: grandtotal: " + grandTotal);
                finishedExecution=true;
                //System.exit(0);
                return grandTotal;
                
            }
            
            //this can be only option when one of the numbers most MSD is not equal to 0
            //hence it completes extra logic
            
            //just to clarify if it reached grandTotal below    412
                                          //                   + 26
                                          //                  ------
                                          //                     38
                                          //                  ------
            //the remainingPortionSecondNumber is still 41/10  = 4
            //whereas remainingPortionFirstNumber is  2%10 = 0
            //hence loop below is applicable
            
            else
            {
                System.out.println("final test 7");
                System.out.println("NOT HERE2");
                
                if (!finishedExecution)
                {
                    System.out.println("final test 8");
                    //this deals with the non-uniform aspect, until then, it continues normally.
                    //this loop might be an overhead to performance, it can be removed potentially
                    //since we know that the flag above finishedExecution would be true if
                    //below remainingPortionFirstNumber && remainingPortionSecondNumber were 0
                    if (number1.isEmpty() || number2.isEmpty())
                    {
                        System.out.println("final test 9");
                        //rest processing of interest is from number, which obtained value above.
                        remainingPortion = number;
                        lastDigitNumberString = remainingPortion.substring(remainingPortion.length()-1);
                        lastDigitNumber = Long.valueOf(lastDigitNumberString);
       
                        System.out.println("remain:"+ remainingPortion);
                        System.out.println("last: " + lastDigitNumber);
                        System.out.println(carryForward);
                        System.out.println("GT:" + grandTotal);
                        
                        //not sure which
                        if ((remainingPortion.substring(0,remainingPortion.length()-1)).isEmpty())    
                        //if (lastDigitNumber==9)
                        {
                            System.out.println("final test 10");
                            System.out.println("single nine left");
                            //this represents only a single nine left
                            //in that case it would take totanotl of it with carry forward
                            total = lastDigitNumber + carryForward;
                            grandTotal = Long.toString(total)+ grandTotal;
                            System.out.println("IJN: " + grandTotal);
                            //System.exit(0);
                            finishedExecution=true;
                            return grandTotal;
                        }
                            
                        //lots pending 9s
                        if (lastDigitNumber==9)
                        {
                            System.out.println("final test 11");
                            System.out.println("GETS JH");
                            total = lastDigitNumber + carryForward;
                            lastDigitNumber=total%10;
                            grandTotal = lastDigitNumber + grandTotal;
                            remainingPortion=number.substring(0, (number.length()-1));
                               
                            addition(remainingPortion, number1, number2);
                        }
                            
                        //end of the 9s
                        else
                        {
                            System.out.println("final test 12");
                            total = lastDigitNumber + carryForward;
                            grandTotal = total + grandTotal;
                                
                            //shrink value
                            remainingPortion=number.substring(0, (number.length()-1));
                            grandTotal = remainingPortion + grandTotal;
                            System.out.println("finished1");
                            System.out.println(grandTotal);
                            //System.exit(0);
                            finishedExecution=true;
                            return grandTotal;
                        }
                        
                        //easiest - done
                         //so  784308  
                         //    +   51   = 784359
                                     
                        if (lastDigitNumber+carryForward<10 && !finishedExecution)     //lastdigit = 3
                        {
                            System.out.println("final test 13");
                            System.out.println("ldn: " + lastDigitNumber);
                            total = lastDigitNumber + carryForward;
                            grandTotal = Long.toString(total) + grandTotal;
                            System.out.println("grad: " + grandTotal);
                            
                            remainingPortion=number.substring(0, (number.length()-1));
                            
                            System.out.println("current remaining check: " + remainingPortion);
           
                            if (!remainingPortion.isEmpty())
                            {
                                System.out.println("final test 14");
                                grandTotal=remainingPortion+grandTotal;
                                System.out.println("finished2");
                                finishedExecution=true;
                                //there is still MSD left
                            }
                            
                            System.out.println(grandTotal);
                            finishedExecution=true;
                            //System.exit(0);
                            return grandTotal;
                            
                        }
                                     //so  784948  
                                     //    +   71   = 785 019
                        if (lastDigitNumber+carryForward>9 && !finishedExecution)     //lastdigit = 9
                        {
                            System.out.println("final test 15");
                            //checks next highest MSD for another 9
                            if (Integer.valueOf(remainingPortion.substring(remainingPortion.length()-1))==9)
                            {
                                System.out.println("final test 16");
                                
                                //it leaves remainingportion intact
                                //remainingPortion=remainingPortion/10;
                                //but sets flag to handle the situation better.
                                System.out.println("current grand: " + grandTotal);
                   
                                addition(remainingPortion, number1, number2);
                   
                            }
                            
                        if (lastDigitNumber!=9 && !finishedExecution)
                        {
                            System.out.println("final test 17");
                            System.out.println("DDD");
                            total = lastDigitNumber + 1;   //carry 1 over
                            grandTotal = total + grandTotal;
                            System.out.println("CURRENT GRAND: " + grandTotal);
               
                            //since it has dealt with lastNumber remainingPortion has to remove this
                            remainingPortion=number.substring(0, (number.length()-1));
                            //remainingPortion=remainingPortion/10;   //now 78
                            System.out.println(remainingPortion);
                            grandTotal = remainingPortion + grandTotal;
                            System.out.println("NEW: " + grandTotal);
                            System.out.println("finished3");
                            System.out.println(grandTotal);
                            //System.exit(0);
                            return grandTotal;
                        }           //so 98499 948  
                                     //    +    71   = 9 8500 019
                        if (!finishedExecution)
                        {
                            System.out.println("final test 18");
                            System.out.println("curent ggrand: " + grandTotal);
                            System.out.println("current remain: " + remainingPortion);
                            grandTotal=remainingPortion+grandTotal;
                            return grandTotal;
                            
                        }
                            
                        }  //end of final test 15
                    }  //end of final test 9
                } //end of final test 8
            }  //end of final test 7
            System.out.println("final test 19");
            
            return grandTotal;
    }  //end of method
   
} //end of class