If you want to execute a Method in the Terminal, you need to use the DO command  with the Method, program and parameters.

Ex. 

DO METHOD^PROGRAM --> Call one Method Without Parameters

DO METHOD^PROGRAM(PAR1,PAR2) --> Call one method with two paramaters.

DO METHOD^PROGRAM(PAR1,PAR2),METHOD^PROGRAM --> Call two Methods in the same command.
 

Thank you Henrique,

But i need to write Excel files with a client server architecture, this is not a web application. I thought in a Class or something like this.

With the bellow code, you will can count all nodes.

USER>S COUNTRY="",COUNT=0,NIV=""
USER>F  S COUNTRY=$O(^Locations(COUNTRY)) Q:COUNTRY=""  F  S NIV=$O(^Locations(COUNTRY,NIV)) Q:NIV=""  S COUNT=COUNT+1
USER>W COUNT
5
 

Count only USA

USER>S COUNTRY="USA",COUNT=0,NIV=""
USER>F  S NIV=$O(^Locations(COUNTRY,NIV)) Q:NIV=""  S COUNT=COUNT+1
USER>W COUNT
3
 

Count only Canada

USER>S COUNTRY="Canada",COUNT=0,NIV=""
USER>F  S NIV=$O(^Locations(COUNTRY,NIV)) Q:NIV=""  S COUNT=COUNT+1
USER>W COUNT
2