Several things kept Anatoly Shcharansky going in his nine years of imprisonment:

"I was playing chess a lot," he says. "I was reminded of some very important moments of my life. I tried to live them again and again. I was trying to remember everything I could remember from my Hebrew, songs which I could remember."

And he never allowed himself to dream about a specific date for freedom. During his years in Soviet prisons, including 430 days in what he called "punishment cells," he saw what such dreams did to others -- and how others coped: "I was sitting with a Ukrainian who was all the time living in his own house, which he never had. And he was drawing the rooms, building them . . ."

A diminutive man, Shcharansky -- mathematician, chess master and the best known Soviet refusenik -- is much slighter and thinner than he appears in pictures that have circulated worldwide since his February release. In a lunch yesterday with Washington Post writers and editors, the wry humor and irreverence that characterized him in the years before his 1977 arrest seemed intact.

His easy, sometimes mischievous wit surfaced even as he talked of the most painful subjects.

Asked how he communicated with other prisoners even when he was in solitary confinement, Shcharansky said, "You can knock on the walls, you can talk through the toilets . . . There are ways." With a little smile, he told a questioner, "If you need the technique, I can show you."

Asked for his impressions of the White House during his visit with President Reagan Tuesday, Shcharansky quipped, "Well, I don't know how it usually is. This is first time I met with an American president, and I wasn't often a guest of the Kremlin, as you probably know."

On the topics of conditions in prison camps and the fate of most "prisoners of conscience" in the Soviet system, he gave sobering but not melodramatic sk,1 accounts. And he portrayed a prison system that he insisted has no comparison in the United States.

At one point, Shcharansky referred to slavelike prisoners -- khimiki, or "chemists," is the slang term -- in the Soviet Union who have partly completed their sentences and serve the remaining time by working at whatever jobs the Soviet authorities decide. Someone suggested this sounded like "halfway houses" in the United States.

"I don't think you have that in America," Shcharansky said firmly. "That's exactly the trouble. People always make something analogous in their system, but they're different things."

Many westerners don't understand the differences between the western and Soviet societies, despite similar terminology, he said. "The very fact that the same words are used -- parliament here and parliament there . . . members of Congress . . . trade unions and trade unions, laws and laws, courts and courts, prisons and prisons . . . It's different institutions from the point of view of their aims."

He spoke favorably of his meeting with Reagan. "People in the Soviet Union don't understand their system so well as the people sitting inside the prison cells," Shcharansky said. "And when I was speaking to the president I was surprised to see that he does understand."

But Shcharansky wouldn't say what Reagan may or may not have told him about the administration's "quiet diplomacy" with the Soviets -- especially any attempts to free such prominent jailed Soviet dissidents as Andrei Sakharov.

"I think it's up to President Reagan to decide what to publicize from his talks," Shcharansky said, adding, "My point of view is that no quiet diplomacy without strong public pressure can help -- in this case Sakharov , too."

On the possibilities for eventual release of Sakharov and for the open emigration of Soviet Jews, he said he was optimistic but "not very." "There is a chance now to open the gates -- and there is a chance also for Sakharov." Of his own release, he said, "They let me go not because they became more human, but because they understood that without solving this problem there will be no progress in the direction they're interested in. At the same time it was like an attempt to make some cosmetic improvement without solving the problem as a whole -- the problem of emigration."

And nothing, Shcharansky contends, will change "as long as they can have hope that they can live without solving the problem, without opening the gates of emigration."

The problem with a liberal emigration policy from the point of view of the Soviets, says Shcharansky, is not the actual numbers of people who would leave:

"Of course, a lot of people would leave . . . But there are many people who would never like to leave the Soviet Union . Nevertheless, the very fact that there would be free choice for every citizen whether to leave or not makes such a big influence on the minds of the people and undermines . . . the foundation of the system that it's a real danger."

Shcharansky, 38, now lives in Israel with his wife, Avital, who is pregnant. He has taken the Hebrew name Natan.

What Shcharansky has seen of America are mainly the faces of reporters across lunch and breakfast tables, he said ruefully. "Everybody eats, I am speaking," he said. "It's like a little hunger strike . . . I think, well, at least I am suffering but not for nothing. I am telling them about conditions in Soviet camps." Except that's not always what gets printed: "The next day I open the paper and find out that my wife is pregnant."

He talked with bemused frustration about people who ask him to conferences to speak and then besiege him with international foreign policy questions on issues like "SALT, like I am Brzezinski or Kissinger," he said.

What he wants to talk about are Soviet dissidents in a system that Shcharansky depicts as closed and controlled, where a display of individuality can bring considerable trouble.

"An essential part of the prison is for the so-called economic crimes," Shcharansky said. "Any displaying of economic initiative -- buying for one price and selling for the other . . . I think there are at least 1 million people in prison for the so-called economic crimes and in this category there are a lot of Jews."

Jewish people, said Shcharansky, "have a different type of mentality. To them, private initiative is a very natural thing."

Shcharansky himself had become involved with Jewish activists and refuseniks in the mid-1970s -- he had been refused permission to emigrate to Israel -- and was eventually tried and convicted on charges of espionage and treason.

"Of course the moment I started as the official spokesman of our movement . . . everybody in the Soviet Union when he starts contacting the press becomes in a very vulnerable and dangerous position. The moment you become a spokesman, that is maybe the first step . . ."

In prison camp, whether you were Jewish had little effect upon your treatment, he said. "If you are ready to cooperate with them and you are Jewish, it's even better -- more profit for them," he said. "If you refuse to cooperate with them -- they're pressing on you all the time -- I can't see that the problem of Jew and non-Jew makes a difference."

There were two main crimes in the political camps: "A hunger strike and refusal to work," said Shcharansky. "Both are punished seriously."

Shcharansky told of what he called "the punishment cell," where food came every second day. "No bed at first, no warm clothes, no pillow and no blanket, no paper for writing, no books for reading. This is the punishment cell."

He analyzed what information he could get in prison, including reading material approved by Soviet censors. Among documents approved for his reading was a book in Russian attacking Zionism. However, the guards overlooked a copy of a letter in English from Reagan to Shcharansky's wife in which the president offered support for Shcharansky. "It was like a hole to another world," Shcharansky said with a smile.

And he never lost sight of the possibility of his own release.

"Well, I always thought that that day may come," he said. "But at the same time I never made any concrete plans, because I saw how people who made such concrete plans . . . they can't think of anything but only that today or tomorrow they might leave. Everything they were doing or they were hearing or they were reading, it was only through this idea. They simply stopped understanding the world.

"That's why I decided not to make any concrete plans -- to be ready to stay there all my life but to be ready to be set free at any moment.

"I was very isolated from others in the camp . . . The KGB always tries to create an atmosphere of general suspicion, which is very easy because there are a lot of broken people who are there."

Shcharansky praised former president Jimmy Carter for his efforts on behalf of Soviet dissidents: "He deserves a lot of credit for raising human rights to such a high level. He put it on a level of state policy."

Of Soviet leader Mikhail Gorbachev, Shcharansky said, "He is a loyal product of this system, but he is ready -- more than the others -- to take into account and try to understand better how the western system works."

And, of course, former Soviet ambassador to the United States Anatoliy Dobrynin understands Americans quite well, he said. "But it's only image. Nothing more."

When Shcharansky left the Soviet Union, his mother, economist Ida Milgrom, and his brother, Leonid, 39, stayed behind. However, he said, Soviet pressure through his family is unlikely to work on him.

"My brother says to me, 'I don't want you to correlate your behavior in any way with us.' "

Now, in Israel, he will first concentrate on his memoir, which will be published by Random House. "I'm not a professional writer and I'm not going to write a fiction book. But what I can write is to share my experiences."

He also hopes to continue work on behalf of Soviet Jewry. "But then I think I'll try to return to my job. For this field, 12 years is a long time."

And he will no doubt try to maintain some balance between celebrity and normalcy. "The best thing is to try and remain yourself and not let people take too much of you."