Tell me how many math problems I have to do! My teacher always gives me the most complicated set of math problems for homework. Like: pg. 546: 17-19, 22, 26, pg. 548: 35-67 odd, 79, 80-86 even. And I want to know in advance how much time to set aside for my homework, but I don't want to have to figure all that out. That's why its your task to program it for me.
Specifications

You will get a string detailing the problems that I have to complete as args, stdio, etc.
They will be comma separated (possibly comma-space separated)
It will include single problems in the form of just a number (e.g. 79)
And ranges in the form 17-18 (again, you have to deal with optional spaces)
The ranges are inclusive of both ends
The ranges will optionally be suffixed by odd or even, which you have to take into account.
A set of ranges/pages will be prepended by a page number in the form pg. 545: , again having to deal with optional spaces. You can safely ignore these, as you need to get the problems over all the pages
The text may be in uppercase or lowercase, but will not be both.
Return, stdout, etc. the number of problems I have to do for homework.
Since this is code-golf, shortest code in bytes wins!

Test Cases
pg. 546: 17-19, 22, 26, pg. 548: 35-67 odd, 79, 80-86 even   -&gt;    27
pg. 34: 1                                                    -&gt;    1
PG. 565: 2-5,PG.345:7                                        -&gt;    5
pg. 343: 5,8,13 - 56 even,pg. 345: 34 - 78,80                -&gt;    70
pg.492: 2-4 odd,7-9 even                                     -&gt;    2
CJam, 61 58 51 48 46 43 41 38 bytes

leuS-',/{':/W&gt;:~_2*2&lt;~z),&gt;1f&amp;\,5--~}%,


Verify the test cases in the CJam interpreter.

How it works

leuS-      e# Read a line from STDIN, convert to uppercase and remove spaces.
',/        e# Split at commas.
{          e# For each chunk:
  ':/W&gt;    e#   Split at colons and only keep the last chunk.
  :~       e#   Evaluate the string inside the array.
  _2*      e#   Copy the array, repeated twice.
  2&lt;       e#   Keep only the first two elements.

           e#   In all possible cases, the array now contains exactly two
           e#   integers, which are equal in case of a single problem.

  ~        e#   Dump the array on the stack.
  z),      e#   Push [0 ... -N], where N is the second integer.
  &gt;        e#   Discard the first M elements, where M is the first integer.
  1f&amp;      e#   Replace each element by its parity.
  \,       e#   Push L, the length of the original array.

           e#   EVEN and ODD all push elements, so L is 1 for single problems,
           e#   2 for simple ranges, 5 for odd ranges and 6 for even ranges.

  5--      e#   Discard all elements equal to L - 5 from the array of parities.

           e#   This removes 0's for odd ranges, 1's for even ranges, -3's for
           e#   other ranges and -4's for single problems, thus counting only
           e#   problems of the desired parities.

  ~        e#   Dump the resulting array on the stack.
}%         e# Collect the results in an array.
,          e# Compute its length.