Just days before he was freed, Kosuke Tsuneoka said one of the militants brought him his new cell phone and asked the prisoner to set it up.
The younger militants were more interested in accessing Al-Jazeera on the phone, but Tsuneoka shifted their attention to Twitter, successfully getting them to ask him to demonstrate how it worked. He then sent the two following tweets: "i am still allive, but in jail" and "here is archi in kunduz. in the jail of commander lativ."
"That's how I got the message out," Tsuneoka told a news conference in Tokyo on Tuesday, a day after he arrived safely back in Japan. "I'm sure they never thought they were tricked."
A couple of days later, the militants — whom Tsuneoka said identified themselves as members of Hizb-e-Islami but posed as Taliban to the Japanese government — set him free in part because he is a Muslim. He had converted to Islam in 2000.
The Japanese government said it paid no ransom to free Tsuneoka. He said he believes that because the captors didn't seem to be overjoyed at the time of his release or suggest they had received any cash.
During his five-month captivity in northern provinces of Kunduz and Takhar, the freelance journalist thought he would never get out alive.
"I thought I would be certainly killed, so I tried to prepare myself to face it," he recalled. His fear reached its peak in late June, when the captors issued an ultimatum to the Japanese government, threatening to kill him if their demands were not met within 72 hours.
When the time passed, and there was no sign they were going to kill him, he started to think he could survive and gain freedom at some point.
"Although it was frustrating that I didn't know when that might be, my fear of death gradually faded and I felt better," he said.
Tsuneoka said after that, anger rather than fear helped him survive the ordeal. Even though his captors fed him well and never used violence, he repeatedly thought about how he could retaliate against them.
"They are a bunch of thieves just trying to extort money from Japan," he said.
The rest was boredom. He had nothing to do but sleep, gaze out the window to see birds or count ants crawling on the dirt floor, when the young militants were not around to talk.
Tsuneoka was kidnapped in April, when he traveled to a Taliban-controlled area in northern Afghanistan, and was released Saturday night to a Japanese Embassy.
Tsuneoka had been abducted before. He disappeared in Georgia in 2001 and was held for several months by unidentified individuals, according to the Committee to Protect Journalists. He was freed during a Georgian military operation.
Despite what he had gone through, Tsuneoka doesn't mind returning to Afghanistan.
"I'm ready to go back right now," he said. "But after all the trouble, I have to think how not to repeat the same mistake. That's the problem."