#include <iostream>
#include <fstream>

unsigned int SLOC(std::fstream *inFile);

int main()
{
    std::fstream filestream ("input.txt", std::fstream::in | std::fstream::out);
    if(filestream.is_open()){
        std::cout << SLOC(&filestream) << '\n';
    }

    filestream.close();

    return 0;
}

unsigned int SLOC( std::fstream *inFile)
{
    unsigned loc = 0;
    bool singleLineComment = false;
    bool multiLineComment = false;
    unsigned int stringLen = 0;
    char c;

    do{
        inFile->get(c);

        if(c == '/' && ( inFile->peek() == '/' || inFile->peek() == '*') && !multiLineComment){
            if(inFile->peek() == '/'){
                singleLineComment = true;
                //inFile->get(c);
            }
            else if(inFile->peek() == '*'){
                multiLineComment = true;
                //inFile->get(c);
            }
        }
        else{
            if(multiLineComment){
                if(c == '*' && inFile->peek() == '/'){
                    inFile->get(c);
                    multiLineComment = false;
                }
            }
            else if (singleLineComment){
                if(c == '\n')
                    singleLineComment = false;
            }
            else{
                if(c !=' ' && c != '\n' && c != ';')
                    ++stringLen;
                else if(c == ';' && stringLen){
                    ++loc;
                    stringLen = 0;
                }
            }

        }


    }while(!inFile->eof());

    return loc;
}
