Mathematical Model for Learning Languages