To fix the floating input, change
pinMode(2, INPUT);
to
pinMode(2, INPUT_PULLUP);
This will stop the counting until you pull pin 2 low with a switch connected between pin 2 and ground.
You may see multiple counts with one switch activation, this is called switch bounce. Due to this behavior, it is generally a bad idea to read switches using interrupts. Interrupts are also very difficult to debug so it is best to avoid them, especially when you're new to Arduino.
Don't forget DeltaG's other fix:
oid brojac(){
volatile counter++;
}