
#include<bits/stdc++.h>
using namespace std;
int n;
int cnt;
bool check(int x)
{
int rev=0,temp=x;
while(temp)
{
rev=rev*10+temp%10;
temp/=10;
}
if(x%rev==0)return true;
return false;
}
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
{
if(check(i))cnt++;
}
cout<<cnt;
}

#include<bits/stdc++.h>
using namespace std;
int n;
int cnt;
int solve(string s)
{
string ss=s;
reverse(ss.begin(),ss.end());
return stoi(ss);
}
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
{
int t=solve(to_string(i));
if(i%t==0)
{
cnt++;
}
}
cout<<cnt;
return 0;
}


二刷
#include<bits/stdc++.h>
#define int long long
using namespace std;
int cnt;
vector<int>v;
bool check(int x)
{
v.clear();
int temp=x;
while(temp)
{
v.push_back(temp%10);
temp/=10;
}
int sum=0;
for(auto &it:v)
{
sum=sum*10+it;
}
if(x%sum==0)
{
return true;
}
return false;
}
signed main( )
{
cin.tie(nullptr)->sync_with_stdio(false);
int n;cin>>n;
for(int i=1;i<=n;i++)
{
if(check(i))
{
cnt++;
}
}
cout<<cnt;
return 0;
}
