A storage algorithm for two-layered neural networks