Really Complicated Math Problem