Assembly (MIPS, SPIM), 238 bytes, 6 * 23 = 138 assembled bytes
main:li$v0,5 syscall move$t3,$v0 li$a0,0 li$t2,2 w:bgt$t2,$t3,d div$t3,$t2 mfhi$t0 bnez$t0,e add$a0,$a0,1 s:div$t3,$t2 mfhi$t0 bnez$t0,e div$t3,$t3,$t2 b s e:add$t2,$t2,1 b w d:move$t0,$a0 li$a0,0 bne$t0,1,p add$a0,$a0,1 p:li$v0,1 syscall Ungolfed
No explanation here, since I'm really busy. I'll be back though!
main: li $v0, 5 syscall move $t3, $v0 li $a0, 0 li $t2, 2 while: bgt $t2, $t3, end div $t3, $t2 mfhi $t0 bnez $t0, end_s add $a0, $a0, 1 sub_while: div $t3, $t2 mfhi $t0 bnez $t0, end_s div $t3, $t3, $t2 b sub_while end_s: add $t2, $t2, 1 b while end: move $t0, $a0 li $a0, 0 bne $t0, 1, skip add $a0, $a0, 1 skip: li $v0, 1 syscall