[Question]
  [
This sentence employs two a’s, two c’s, two d’s, twenty-eight e’s, five f’s, three g’s, eight h’s, eleven i’s, three l’s, two m’s, thirteen n’s, nine o’s, two p’s, five r’s, twenty-five s’s, twenty-three t’s, six v’s, ten w’s, two x’s, five y’s, and one z. 
Such sentences are called [autograms](http://en.wikipedia.org/wiki/Autogram). Your task is to write a program or function that has a similar property: it takes as input a byte, and outputs an integer representing the number of times that byte appears in the program's source code. It should output 0 if its input doesn't appear in its source.
**Your program must not read its own source code**, directly or indirectly, but instead all the data it needs to give its output must be hard-coded, quine style. Your program must be at least one byte in length.
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest entry (in bytes) wins. I won't accept an answer, so feel free to compete for the shortest solution in your favourite language.
You are strongly encouraged to include an explanation in your post.
## Leaderboards
Below are leaderboards both for overall score and per language:
```
var QUESTION_ID=162408,OVERRIDE_USER=21034;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
```
```
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
```
```
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>
```
  
[Answer]
# [Octave](https://www.gnu.org/software/octave/), 44 bytes
```
@(x)sum([[39,'(())*,239==@[[]]msuxx']]==x)*2
```
[Try it online!](https://tio.run/##dYxBCoMwEEX3PUU2ZWZkEKorKQPeI80iiBYXRhtNSXv5VCktddHl@7z3x2ax9zZ1kud5qjHSHAbUuqwYEIkyLspKpNbamGEOMYIxIpGyIk1@vCpRsI82fPPqlNXWiazzJ4PzYfK9WzrUvp0GuyAcG6WAT@zcE4Prb6HF7ZuIGC4O@Ov1/zzD@ndgZb23jy447HhnGkov "Octave – Try It Online")
The result of the function, when using each of the characters in the function as input:
```
'  (  )  *  ,  2  3  9  =  @  [  ]  m  s  u  x  
2  4  4  2  2  2  2  2  4  2  4  4  2  2  2  4  
```
All other input characters returns a zero.
The fact that I had to escape `'` made this a whole lot longer. In order to account for the 4 parentheses, I just had a duplicate in the string. However, duplicating apostrophes takes apostrophes, so this just takes us further from the correct result. Therefore, I had to count the number of apostrophes with its ASCII-value, `39`. This of course meant I had to check for the characters `3` and `9` too, making it all a lot longer.
[Answer]
# Excel, 84 bytes
```
=IFERROR(MID("65496331125442343343233",FIND(A1,"""123456789,()=MINORFADEOMEN"),1),0)
```
`Find()` will look for the value in cell `A1` within the string `"123456789,()=MINORFADEOMEN` (the `"""` at the beginning is to escape the character and will evaluate to just `"`).
Based on the result of `Find()`, the `Mid()` function will return the corresponding character from the string of numbers. This string was created through iteration until it stopped changing.
If the character in `A1` is not found, `Find()` returns an error so the `IfError()` function escapes that to return `0` instead.
The `OMEN` at the end of the string being searched in the `Find()` function are duplicate letters so their position will never be returned but they were needed to adjust the character counts. Without them, there was an endless loop of changing counts. The letter arrangement is stylistic choice.
[Answer]
# JavaScript (ES6), 70 bytes
Doesn't read the source of the function, but this is quite long. Takes input as a 1-character string.
```
i=>~(n='\\34=\'in(|)0257?:.>[]Odefx~'.indexOf(i))?'3733544333'[n]||2:0
```
[Try it online!](https://tio.run/##VY9Pa8JAFMTvforXHtxdEpc0m1SIjVKEQqHgwd6Mh/zZTTamu5KsRWj0q6cbvbS3NzPwmzd1@p12eSuPZqZ0wQcRDzJeXrGKUZKwIE6QVLgnnh/OVxFd7vabgovzFVGpCn7eCCwJWSE2ZywMAsYY2ql93/uRNwjd4gxi8BaQwQv44bM9HIfAzwQgt8HWtFKVVLT6a12l7drW44wsbIprGwucEwLTKeRadbrhtNElRp8Vh06f2pyPvkml6pALtQvoEYFjuc54kYmlSGE5DzHgw0ijRt8LMaHdsZHG4mnDVWkqmMETuf8F/9veXt8/tmCXwB96BKU2MOp61C50lT41BWT8Zh5uEy6Ty/AL "JavaScript (Node.js) – Try It Online")
[Answer]
# [Retina](https://github.com/m-ender/retina/wiki/The-Language), 1 byte
This wouldn't be valid if following strictly the quine rules, but the OP explicitely allowed it [in a comment](https://codegolf.stackexchange.com/questions/162408/autogram-programs#comment393488_162408).
```
x
```
[Try it online!](https://tio.run/##K0otycxLNPz/vwKIAA "Retina – Try It Online")
In retina a single-line program counts the occurrences of that regex in the input. This challenge is solved by any single ASCII character except ```, `.`, `+`, `*`, `?`, `[`, `(`, `)`, `^`, `$`, `\` and newline.
[Answer]
# [C# (Visual C# Compiler)](http://www.mono-project.com/docs/about-mono/releases/5.0.0/#csc), ~~88~~ 57 bytes
```
x=>"\\\"(())==>>??..::3300CCaaiinoossttx".Contains(x)?3:0
```
[Try it online!](https://tio.run/##LY69asMwFIVn6ymE6CBBKwzenEoeDJlSKHToUHcQquwIEgl0b4uL8bPfqiSc8fx8x8OTB0@M@YsD4K8lL8VdWbOxpgF0GD3/yfGLv7iYJGCJafn45K4soGpiY2@/gOGqj9/JP9/sRx4TWj5zQ6uxYpomIaVSxlg7DFr3fde17Tg6F2PKGQBxFXrMCSsB5KqGrm/pwNicS3D@fIdyqLM3br12p9YW5EvQ7yViOMUU5IPYYO/5NktQu1AHtv@LSJAkRY4MWRr@AA "C# (Visual C# Compiler) – Try It Online")
Returns **3** if the string contains the passed char, otherwise returns 0.
The string contains each character of the code atleast once and exactly the amount required to have the char **3** times in the code.
-31 bytes thanks to [Kevin Cruijssen](https://codegolf.stackexchange.com/users/52210/kevin-cruijssen)
[Answer]
# [Haskell](https://www.haskell.org/), 66 bytes
The first two versions are essentially a quine which filters the required characters and then takes the length:
```
q c=length.filter(==c)$id<>show$"q c=length.filter(==c)$id<>show$"
```
[Try it online](https://tio.run/##hcoxDsMgDADAr1hVBlh4QcySrn2EFdxghZgAlvp82h90uO0yjZNLmXLdtRs8ySi8qlZJ4NwavZ8Ndiysh@XwlmLcHeLuF0lrHLl@lsffMC8SBYSDbatqrDYgRoS7ixoEaD@ZKc32BQ "Haskell – Try It Online") or [test with all characters!](https://tio.run/##jU67DoIwFN35ipOGBIhCdDXURUeddAOHplRpLC2PEhb/HQsOGhc9y725555Hybq7UGqUVW1aiz2zLDkabWSBMEy3UTQ24FQJfbNlcpXKijaklEe@LNJtV5rBJz8fRq9iUoOiMB5Q9/Zk24OGD7IzhdjkmmCxAHf7J03iN8iX7iw6u8EsmyIQMqVg3RFZkK@CJLlEnpMMpWjFbAy4@J9N8z8@piovzHnc@XZ9hQxrPMADpPEcuJx2Sh1/mYbzHZsn "Haskell – Try It Online")\*
---
### Alternative without `(<>)`, 72 bytes
```
q c=length.filter(==c)$(++)<*>show$"q c=length.filter(==c)$(++)<*>show$"
```
[Try it online](https://tio.run/##jcrBDYAgDADAVRrjQyRhAsvHSQhWIWIRaOL46Ag@7nfBtZNS6r2Ax0R8SDB7TEJ1QvRqnLRWy2xbyM84/Dn9cpEB4SBZMwuxNLAW4a6RBQyUTyC39fIC "Haskell – Try It Online") or [test with all characters!](https://tio.run/##jU49D4IwFNz5FZeGBLBCdDXUxdVNN2AgpVpiAaElLP53bHHQOHHLe3n37kOW@iGUmucenCnR3o1MbrUyYggZ45EfUhqlm6OW3eSTNT@z15R1C4aq84DnaC5mOLfwQU5dJQ55S0ApuN1/aRJ/Qf50V6HNAYvMRSAslYKxR2RBvguSpIg8K5mkGMRiDNj4NWXzdU@u0AdLKrfuemyQYY8XeIA0XmK3bmfM8oUb1nru3w "Haskell – Try It Online")
---
### Non-quine alternative, ~~87~~ 86 bytes
Might still be improved, but I'm happy that I got it down to only three different groups.
I like this one the best, even though it counts the most bytes. It's computes the character/byte count by as a sum of *2,3* and *7* (note how some characters are in multiple groups):
```
u t=sum[fst e|e<-[(2," ()-237<=dflnst|"),(3," ()[\\]`mstu"),(7,"\",ee")],t`elem`snd e]
```
[Try it online](https://tio.run/##Hci9DoMgEADgV7kwQYIddHARlz4GkEDCWU2BNt6x@e70Z/iWb4/0xJx7b8CGWrEbMeCFy2DlqAVINYzTvJi05Up8CaXl9G/rnA@FuP1q1sIJjSiU1xwwYwlUE6DvJR4VDDyQ76/KWJlgXQ28z6My3KB97RhTxw8 "Haskell – Try It Online") or [test with all characters!](https://tio.run/##bY9Ba4NAEIXv/orHUFDJGtrkEAh6yrW39uYsKDrB0FVDdiUX/7tdtaWl6Vx2eMPb976mtB9izDQNcJkd2vxsHWSUNMmjnSJEcbLbH9KsPpvOupFiFe0XOWfWRWvdMEsHRUxKhGKtXCFG2sJ2NURPQVteOmSo@wC4Du7N3V47PIFOfS1H7gibDSq//z5T8jP0x/cu1h2x2GzT3xGVxsB5EXnIz@F2q@PAW@6N3GT52IfTv3D8QMcrHn/xfRPyisjklZmSHzDnkussTSqf6eOQ4wUjqhBpslRR855l/q7nZ0A1fQI "Haskell – Try It Online")
---
\* imports `(<>)` because TIO's GHC version is 8.0.2
[Answer]
# [Python 2](https://docs.python.org/2/), ~~54~~ ~~52~~ 32 bytes
-20 bytes thanks to ovs
```
("''+.23cnotu()"*2+'"*'*3).count
```
[Try it online!](https://tio.run/##JYzLCoMwEEX3@YphNnloBeNOyJeULsqYUKHMiB0Fvz5VXJ7DuXc59CMcK8mUEyJWh9Y2XRyIRTfnMcTGYrBh8B3JxlrP6NmPj/5lSsr7@@uuqTdFViCYGX5ZbzUagGWdWYHa4sindOn75cT6Bw "Python 2 – Try It Online")
[Answer]
# [Husk](https://github.com/barbuz/Husk), ~~11 10~~ 8 bytes
Thanks [Leo](https://codegolf.stackexchange.com/users/62393/leo?tab=profile) for -2 bytes!
```
#sD"#sD"
```
[Try it online!](https://tio.run/##yygtzv7/X7nYRQmE////r66kDgA "Husk – Try It Online")
### Explanation
This makes sure that it only uses ASCII (because `show` would mess it up) and that each character is contained twice:
```
#sD"#sD"  -- character as input, eg. '"'
   "#sD"  -- string literal (note the redundant '"'): "#sD"
  D       -- double: "#sD#sD"
 s        -- show: "\"#sD#sD\""
#         -- number of occurences: 2
```
## Standard quine extension, 11 bytes
```
#hS+s"#hS+s
```
[Try it online!](https://tio.run/##yygtzv7/XzkjWLtYCUz@//9fXUkdAA "Husk – Try It Online")
### Explanation
```
#hS+s"#hS+s  -- character as input, eg. '"'
     "#hS+s  -- string literal: "#hS+s"
  S+         -- join with itself: ("#hS+s"++)
    s        -- | and itself shown: "\"#hS+s\""
             -- : "#hS+s\"#hS+s\""
 h           -- init: "#hS+s\"#hS+s"
#            -- number of occurences in string: 1
```
[Answer]
# Java 10, ~~164~~ ~~81~~ 57 bytes
```
q->"q-->>\\\"..ccoonttaaiiss(())??33::00".contains(q)?3:0
```
Port of [*@Hyarus*' C# answer](https://codegolf.stackexchange.com/a/162552/52210), so make sure to upvote him!
**Explanation:**
[Try it online.](https://tio.run/##lVCxbsJADN35CuuW3AnlFClbUJOpY1kYCYPrhHIQLiRnkBCiv546IVLVsdKdZD/b7/n5iDeMj9VpoAZDgA90/rEAcJ7rfo9Uw3pMJwBIb7h3/gvIrAR8ypcXGNkRrMHDGwxdnKsujvO8LEtlLVHbemZE50LQ2piiSNMsSxJlSQqiFnRnijRLhtVCyC7Xz0bIZs5b6yo4S9MsvN0Bmtc@uE12lg7YB21s5QI7Tyzhvu3fkQ6a4pzrwFqPPYbMtDHAhEUQ/Um/o9nPr5tJeaqO82L4pbq5B67Ptr2yvchC3HhNS5WVrJbe0hgrM3M9h/kW/77EDw)
```
q->      // Method with String parameter and integer return-type
  "q->\\\"..ccoonttaaiiss(())??33::00".contains(q)?
         //  If the string above contains the input character
   3     //   Return 3
  :      //  Else:
   0     //   Return 0
```
---
**Old [quine](/questions/tagged/quine "show questions tagged 'quine'") 164-bytes answer:**
```
c->{var s="c->{var s=%c%s%1$c;return s.format(s,34,s).replaceAll(%1$c[^%1$c+c+']',%1$c%1$c).length();}";return s.format(s,34,s).replaceAll("[^"+c+']',"").length();}
```
**Explanation:**
[Try it online.](https://tio.run/##jZHBasMwDIbvfQphFmKT1DC200IHe4D10mPWgqe6bTrHCbYSGCV79cxJM7rcCpbRJ8vyL/msWrU87796NMp7eFeFvSwACkvaHRRqWA84BgA5npQDFFkIdcHC8qSoQFiDhRX0uHy9tCHFr9jNjTDy0eMDZk5T4yx4eahcqYj79Ok59UI6XZvw1JsxfMjLd8OeYBJv43RwBxPSaHukExdZx@6pxPIdm2ow9v92ny2C7rr5NEH3JL@tij2UoXe@IVfYY74FJa6Nk/bEYx@PTf@hniPMkc0R59jN8Seexnkb5qhmPJ3mfVWy@fakS1k1JOsgkozlmLCXD2KJleFvxFSo638B)
```
c->{                                  // Method with char parameter and integer return-type
  var s="c->{var s=%c%s%1$c;return s.format(s,34,s).replaceAll(%1$c[^%1$c+c+']',%1$c%1$c).length();}";
                                      //  Unformatted source code
  return s.format(s,34,s)             //  Create the formatted source code (the quine),
          .replaceAll("[^"+c+']',"")  //  remove all characters not equal to the input,
          .length();}                 //  and return the length
```
[quine](/questions/tagged/quine "show questions tagged 'quine'")-part:
* The String `s` contains the unformatted source code.
* `%s` is used to input this String into itself with the `s.format(...)`.
* `%c`, `%1$c` and the `34` are used to format the double-quotes.
* `s.format(s,34,s)` puts it all together
Challenge part:
* `.replaceAll("[^"+c+']',"")` removes all characters except those equal to the input.
* `.length()` then takes the length of this String.
---
NOTE: `.split(c).length` (with `String` input instead of `char`) may seem shorter, but has two problems:
1. The first character gives an incorrectly result, so if `c` (with `c->` as leading part) is input, it will incorrectly return one character too few. This can be fixed by adding `+(c==99?1:0)` in both the source code and unformatted source code String (and changing `.split(c)` to `.split(c+"")`, but then we still have the following problem:
2. If a regex character (i.e. `$`) is input, the `.split` will interpret it as a regex, giving an incorrect result.
[Answer]
# [Haskell](https://www.haskell.org/), 58 bytes
```
f c=sum[2|x<-succ '!':"f c=sum[2|x<-succ '!':,x==c]",x==c]
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/P00h2ba4NDfaqKbCRre4NDlZQV1R3UoJu7BOha1tcqwShPqfm5iZp2CrkJ5a4pyRWKRgZ2erUFCUmVeioKeQ9r8YAA "Haskell – Try It Online") or [verify the solution](https://tio.run/##pY8xD4IwFIR3f8WTmBSSgoaERemko/8AGGop0FhaQh8JA/8dqzi6ecvLXb68y3XcPaXWq@oHOyLcOPLkrhyuDQjmpr5IlzmP3SQEkD05B79jOjMmqmA7a8@VAQa1hR14cchjaCVerUFp0H3CYVQG4QBmehShoMpR19lJ1xEsIPK4IOWJJAkp0ywjFQUtEZTzT33/BTbUOy1Ni13YKI1yDH15xCP6Bo/sC1V/DHkB "Haskell – Try It Online").
Same byte count alternatives:
```
f c=sum[2|x<-tail$show"f c=sum[2|x<-tail$show,x==c]",x==c]
f c=sum[1|x<-id<>show$"f c=sum[1|x<-id<>show$,x==c]",x==c]
```
---
### [Haskell](https://www.haskell.org/), 90 bytes
```
sum.($zip"1234\"$,.[\\]opu+()iklmsz652"$[4,4,11,3,3,3,16,5,3,3,3,3,3,3,3]++[2,2..]).lookup
```
[Try it online!](https://tio.run/##LcYxCsMgFADQq4gISfBX0JhsmXqBjAV1kFJbiUapdcnha6GEt7yXLdsjhObQolupkfXk8BlzMUqNCTCltUm50n7wW4jlmCeBiZIggXMY//gM09mToVQJEIyZgYWUtppbtH5HC8pvv38QQQ510LXv3QX7LO1yu67rDw "Haskell – Try It Online") or [verify the solution](https://tio.run/##tY8xb4MwEIX3/IoTQgIL4xYHsiRMydghYyWbwXEcsDA2wmaJ@ttLacpf6HvLvdOnO71O@F4Zs@hhdFOAiwiCfGgfdhZqvvh5IGn81GNU0H3JoxgTxnnjxjlLke7N4J@HikYxK3GJiwLvXy4OuNrGzU2WMYopIQ0ixrl@HpdB6PUF3B3sYJWAUw6tCmdng7LBv5bjpG2AGOx8Y6nE2mPfudncEXyBPOUs4e8JIQmnVZU0GIwKoP161II8wh@6JqNsG7r0oU1QU1rXEgmEf8G3eoOafyz6LR9GtH7JP8/X6w8 "Haskell – Try It Online"). Uses the fact that `sum Nothing = 0` and e.g. `sum (Just 4) = 4`.
[Answer]
# [Smalltalk](https://en.wikipedia.org/wiki/Smalltalk), 112 ~~132~~ bytes
Smalltalk isn't exactly known for its golfing suitability :-)
Method defined in class Character (tested in VA Smalltalk and Squeak, should work in other dialects such as VisualWorks and Pharo as well):
```
a^(0to:6),#(10 18)at:(#('' ',[]^|+68cForu' '#0adefln' '1it' '()' ':s' ' ' '''')findFirst:[:s|s includes:self])+1
```
Characters occurring in the source are grouped by occurrence count. The groups are tested for the first one which contains the receiver, and the matching occurrence count is returned.
### Old method:
```
a^('''''((((())))):::[[[[]]]]^^^^^0000066666aaaacccccdddddeefffFFFFFiiilllnnnnnrrrrrsssTTTTTuuuu'includes:self)ifTrue:[6]ifFalse:[0]
```
Every character that does appear in the method appears exactly 6 times (by being repeated in the string constant), so the method just checks whether the receiver is contained in the string and returns 6 if it is, 0 otherwise.
After defining the method as above, you can validate it using
```
| code |
code := Character sourceCodeAt: #a.
((0 to: 255) collect: [:b | b asCharacter]) reject: [:c | c a = (code occurrencesOf: c)]
```
The result should be empty.
[Answer]
# JavaScript, 31 bytes
```
f=c=>~-`f=${f}`.split(c).length
```
[Try it online](https://tio.run/##LcuxDsIgEADQXyGNw5GmN7vQn3BUkyMUKg3eESGVxNhfx8W3v83utrhXzHViWXzvwTgzHxMFc/qEL2HJKVZwGpPntT66Ey6SPCZZ4YqI7N/q4iv8w5n0HZ82QzNzGwdl1DAGaFrjJpHpxqT7Dw)
[Answer]
# [Python 2](https://docs.python.org/2/), 57 bytes
```
lambda c,s='lambda c,s=%r:(s%%s).count(c)':(s%s).count(c)
```
[Try it online!](https://tio.run/##TYxBCsMgFAX3PcVr4PMVbBZdCvYk3Zgv0kCiQQ00vbxtd9nNzGK2o71yuvfonn3x6xQ8xFTHJ6ZiVSWqepS8p6ZE8z@cvMdcIJgTBhArbUbr/CRhWVMute3X9/EZ7AXYypwamApuD1BgUmIQfwfdvw "Python 2 – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 17 bytes
```
2"D34çýs¢"D34çýs¢
```
[Try it online!](https://tio.run/##MzBNTDJM/f/fSMnF2OTw8sN7iw8tQmL@/394LwA "05AB1E – Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), 96 bytes
```
n"n"=15;n"="=14;n" "=2;n";"=13;n"\\"=3;n"\""=25;n"0"=2;n"1"=4;n"2"=4;n"3"=4;n"4"=5;n"5"=5;n n3=0
```
[Try it online!](https://tio.run/##bY3LDoIwEEX3fgWZuIBEI8@NOF/CZdEFCrFODNKd/16HVuLGpJlzO73pGc3rPljrvZAQF02rU1krE@JS0eq1UgLEgaT7tZfH94J4bZcRVURNvFaagEQqzr1hEqwnWBSIHlCC8BOoRXRBZfj6QiZEJyjfugWCCVRuodpCjaAFNfj5afcwk/BznmTZd6k72EFuy5heJ7sMc8rsMpNlb3c5moOk7tz12Yn/dXr/AQ "Haskell – Try It Online")
# [Haskell](https://www.haskell.org/), 109 bytes
```
n 'n'=15;n '='=14;n ' '=14;n ';'=13;n '\\'=3;n '\''=25;n '0'=2;n '1'=5;n '2'=4;n '3'=4;n '4'=5;n '5'=5;n n3=0
```
[Try it online!](https://tio.run/##nY3LCsIwEEX3fkUowqRQsU3aVZ0vsS6yiDYYB6nJzn@PeVTcCIKre@bODGdWj6u2NgRiQIDdMEbACH0C9oYxgkwwTYAFAFDk6zZCyg4wzwIw/8g1@7UfSpLENiisfgtFEX6UySnFn85qc1OG8L4Yctsj943VdHEzPxvr9MIRfa3q@ukPO9UQ83v8tj@FFw "Haskell – Try It Online")
# [Haskell](https://www.haskell.org/), 122 bytes
```
n 'n'=21
n '='=14
n ' '=14
n '\n'=12
n '\\'=4
n '\''=32
n '0'=2
n '1'=5
n '2'=5
n '3'=3
n '4'=5
n '5'=5
n nnnnnn4'''''''=0
```
[Try it online!](https://tio.run/##bY7BDsIgDIbvPgVZTLolMw623eyTiAcO0y1iY@a4@e4IBTwYe/k/Wpp@s3ndJ2u9JwEEqOQuAALKIYIooMNMKiYNmFoA2HOrC3sxJeAYU@Xsw4eYQ36PKYlrgFTYeYNVua6pnGcSX9LJIDNLZGYN5ujBEEUYVIGowjCUzpjh16baPcxC@FwX2vbn2rV2ots219fFbtNaI7rGNM3bnQ6mJeGO@G9@8R8 "Haskell – Try It Online")
# Explanations
These answers are not terribly sophisticated. It is a series of declarations, one for each character present in the program. At the end we have a catch all that returns 0 for characters not present in the program.
I use a couple of tricks to minimize the number of characters necessary in the program and from there I fiddled with things until the numbers turned out just right. You can see that I've padded the variable name in the last declaration, in all 3 of them. The difference between the 3 programs is whether I chose to use a new line or `;` for line breaks and whether I chose to take Chars as input or Strings. The `;` approach doesn't seem inherently superior to the others it just gets luck and ends up shorter, however it does seem that using Strings is a better idea than Chars because Chars require spaces after the function name an Strings do not.
[Answer]
# [Whitespace](https://web.archive.org/web/20150618184706/http://compsoc.dur.ac.uk/whitespace/tutorial.php), 140 bytes
```
[S S S N
_Push_0][S N
S _Duplicate][S N
S _Duplicate][T N
T   S _Read_STDIN_as_character][T   T   T   _Retrieve][S S S T  S S T   N
_Push_9][T  S S T   _Subtract][S N
S _Duplicate][N
T   S S T   N
_If_0_Jump_to_Label_TAB][S S S T    N
_Push_1][T  S S T   _Subtract][S N
S _Duplicate][N
T   S S N
_If_0_Jump_to_Label_NEWLINE][S S S T    S T T   S N
_Push_22][T S S T   _Subtract][N
T   S T N
_If_0_Jump_to_Label_SPACE][N
S T N
_Jump_to_Label_PRINT][N
S S S T N
_Create_Label_TAB][S S S T  S S T   S T N
_Push_37][N
S T N
_Jump_to_Label_PRINT][N
S S S N
_Create_Label_NEWLINE][S S S T  S S S S T   N
_Push_33][N
S T N
_Jump_to_Label_PRINT][N
S S T   N
_Create_Label_SPACE][S S S T    S S S T T   S N
_Push_70][N
S S N
_Create_Label_PRINT][T  N
S T _Print_as_integer]
```
Letters `S` (space), `T` (tab), and `N` (new-line) added as highlighting only.  
`[..._some_action]` added as explanation only.
70 spaces, 37 tabs, and 33 new-lines used.
Usually I use the Create Labels in the order `NSSN`, `NSSSN`, `NSSTN`, `NSSSSN`, `NSSSTN`, `NSSTSN`, `NSSTTN`, etc. But because printing a number where the binary `S=0`/`T=1` is used affects the number I need to output, I used the labels `NSSN`, `NSSSN`, `NSSTN`, and `NSSSTN` instead, which gave the perfect amount of spaces/tabs to be printed with the binary numbers `SSSTSSSSTN` (33; amount of new-lines), `SSSTSSTSTN` (37; amount of tabs), and `SSSTSSSTTSN` (70; amount of spaces).
### Explanation in pseudo-code:
```
Character c = STDIN-input as character
If c is a tab:
  Print 37
Else if c is a new-line:
  Print 33
Else if c is a space:
  Print 70
Else
  Print 0
```
### Example runs:
**Input: space**
```
Command       Explanation                   Stack       Heap     STDIN   STDOUT   STDERR
SSSN          Push 0                        [0]
SNS           Duplicate top (0)             [0,0]
SNS           Duplicate top (0)             [0,0,0]
TNTS          Read STDIN as character       [0,0]       {0:32}   \n
TTT           Retrieve                      [0,32]      {0:32}
SSSTSSTN      Push 9                        [0,32,9]    {0:32}
TSST          Subtract top two (32-9)       [0,23]      {0:32}
SNS           Duplicate top (23)            [0,23,23]   {0:32}
NTSSTN        If 0: Jump to Label_TAB       [0,23]      {0:32}
SSSTN         Push 1                        [0,23,1]    {0:32}
TSST          Subtract top two (23-1)       [0,22]      {0:32}
SNS           Duplicate top (22)            [0,22,22]   {0:32}
NTSSN         If 0: Jump to Label_NEWLINE   [0,22]      {0:32}
SSSTSTTSN     Push 22                       [0,22,22]   {0:32}
TSST          Subtract top two (22-22)      [0,0]       {0:32}
NTSTN         If 0: Jump to Label_SPACE     [0]         {0:32}
NSSTN         Create Label_SPACE            [0]         {0:32}
SSSTSSSTTSN   Push 70                       [0,70]      {0:32}
NSTN          Jump to Label_PRINT           [0,70]      {0:32}
NSSN          Create Label_PRINT            [0,70]      {0:32}
TNST          Print as integer              [0]         {0:32}            70
                                                                                  error
```
Program stops with an error: No exit defined.  
[Try it online](https://tio.run/##K8/ILEktLkhMTv3/X0FBgQsIgYiTi1OBk5MTKADEIA6QBkqBOQpoImABoGqoNJDJxQXGMMVgabgYVEgBIQRTBTYDZD1QgBPoGgA) (with raw spaces, tabs, and new-lines only).
**Input: tab**
STDIN will be `\t` (`9`) instead, in which case it will be `0` at the first `If 0` check, goes to `LABEL_TAB`/`NSSSTN`, and will push and print `37` instead.
[Try it online](https://tio.run/##XY1dCsAwCIOf4ylytVEK29tggx7fpaE/MFTUL0Hbeb31uY9SM0mGQokAAQio@qIuyQt/xEDuIWuMcE2z5cUG4kbT5Rv9vQAy8QE) (with raw spaces, tabs, and new-lines only).
**Input: new-line**
STDIN will be `\n` (`10`) instead, in which case it will be `0` at the second `If 0` check, goes to `Label_NEWLINE`/`NSSSN`, and will push and print `33` instead.
[Try it online](https://tio.run/##XY1RCoAwDEO/k1PkaiID/RMUPH7NwqYgbWn7Etp72692HsvaqiTR4QQhAAauvrhbyqIfCbB7yB7J1DRHftlA@tB05UZ/b4AqPg) (with raw spaces, tabs, and new-lines only).
**Input: anything else**
Any other input-character will do `NSTN` (Jump to Label\_PRINT) after the third `If 0` check, printing the `0` that was still on the stack (which we've duplicated at the very beginning).
[Try it online](https://tio.run/##XY1RCsAwCEO/4ylytVEK69@ggx3fpaHtYKioL0Gfs921X0epmSRDoUSAAARUY1GX5IU/YiD3lDVGuJbZ8mYT8UPL5RvjvQAyyws) (with raw spaces, tabs, and new-lines only).
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 27 bytes
```
\Ua"" a a a " ÄU\\\"a "aU Ä
            " ÄU\\\"a "     // Given this string literal,
                       aU   // find the last index of the input
                          Ä // and add +1.
\Ua"" a a a                 // Do nothing useful, but make the results match.
```
Longer than the existing Japt answer, but uses a different approach.  
Has the inherent limitation that all chars need to occur a unique number of times. 
Takes input as a string.
[Try it online!](https://tio.run/##y0osKPn/PyY0UUlJIREMlRQOt4TGxMQoAZmJoUDO///qieoA "Japt – Try It Online")
[Answer]
## Perl, 130 bytes
```
+print+0+((0)x40,6,6,0,3,43,0,0,0,22,12,6,3,5,2,4,0,1,0,0,0,1,0,1,(0)x28,1,0,1,(0)x6,1,(0)x4,1,(0)x4,1,1,1,0,2,0,1,0,0,0,5)[ord<>]
```
Has no newline or other whitespace. Reads a line from the standard output, but only cares about its first bytes, then prints the number of times that byte occurs in its own source code in decimal, without a newline.
The program is straightforward. Most of the source code is occupied by a literal table that gives the answer for the each possible byte. Trailing zeros are omitted, and adjacent zeros are run-time compressed, but there's no special trick other than that. The rest of the program simply reads the input and looks up the answer in the table. 
For example, the part `22, 12, 6, 3, 5, 2, 4, 0, 1, 0` in the source code gives the frequency of digits, so there are 22 zeroes, 12 ones, 6 twos etc in the source code. As a result, if you enter `0` to the standard input of the program, the program will print `22`.
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 1033 bytes
```
#include <stdio.h>
int main(int argc,char *argv[]){int r=0*14811;switch((int)argv[1][0]){case' ':r=6;break;case'"':r=3;break;case'#':r=2;break;case'%':r=2;break;case'\'':r=101;break;case'(':r=5;break;case')':r=5;break;case'*':r=5*1*1;break;case'.':r=2;break;case':':r=51;break;case';':r=103;break;case'<':r=2;break;case'=':r=52;break;case'>':r=2;break;case'[':r=4;break;case'\\':r=3;break;case']':r=4;break;case'0':r=11;break;case'1':r=20;break;case'2':r=20;break;case'3':r=9;break;case'4':r=7;break;case'5':r=12;break;case'6':r=3;break;case'7':r=2;break;case'8':r=5;break;case'9':r=2;break;case'a':r=106;break;case'b':r=51;break;case'c':r=55;break;case'd':r=4;break;case'e':r=102;break;case'f':r=2;break;case'g':r=4;break;case'h':r=4;break;case'i':r=10;break;case'k':r=51;break;case'l':r=2;break;case'm':r=2;break;case'n':r=8;break;case'o':r=2;break;case'p':r=2;break;case'r':r=108;break;case's':r=53;break;case't':r=8;break;case'u':r=2;break;case'v':r=3;break;case'w':r=2;break;case'{':r=3;break;case'}':r=3;break;}printf("%d",r);}
```
[Try it online!](https://tio.run/##ZZPNroIwFIT39ykIxvATNRRRUcQXQRa1IDQqmoK6MDw7l5ZNm9k1X@bMmU5TtqwYG4YZb9j9XZTWse0K/lzVpz/edNaD8saVByoqtmA1FZY/Hj9Z7v0kFmngkygmJGm/vGO1K8WeUpA8C0YVo23pWM5BpNvkIkp6SxSxJVnrZCZJqJM5kLMjEQmIDl3JNjrxgPiK@MQ3Jlew4KB0hiiZVhpZjzCYqkEDnUCUSRIZFzpDDzmIApXACEWUd6CjENFaor1OIkl2OtkocyPmFjLt4CoxVLwHDZ2aM979ggUzhQyvAjooJy/D/wobK5irgfDJSUc3DHUH7weQRpJYJ0/QvICIab8x16oARuUdmL/B6gMP9QXNDzS9TvqXGH/s1bXnhb0QXtIPwxD@Aw "C (gcc) – Try It Online")
This is by NO means a golfed answer, but it was fun to try to accomplish this challenge in a language which I am not familiar with. It wasn't a particularly difficult challenge until it came time to find the occurrences of the digits, now THAT was a challenge. Had to do a little creative balancing :) 
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 192 bytes
```
F(J){J=J-70?J-40?J-41?J-74?J-'{'?J-'}'?J-39?J-48?J-49?J-50?J-51?J-52?J-53?J-54?J-55?J-56?J-57?J-47?J-61?J-63?J-45?J-58?J-59?0:1:23:23:23:1:2:3:3:4:4:14:14:10:10:15:6:4:2:2:25:1:1:1;}//84332211
```
[Try it online!](https://tio.run/##PYzPCoJAGMTvPsUSRBpJ7j81Jbp18BXKg2xmHrLYrIv47Ns3JjkfP4aZWU3YGOPc0S@CodgXYRIdilBN4IREEVbDChxBuUOVAnAaS42lFoAE8EZrIAYSjIEYuxgTNbX4i94dooxnQs5HNpMkReK/i6bTWUyRgDStSPm43aZKSiE4d23Xs3vVdj5MZRuzYeZWWbYm/zmVARs8Rt/csj2r@kfrTyUvg/xf2vpF5RHNnD4t5Vd/sbycu8WG@jm3df@2HYtyb3ROpV8 "C (gcc) – Try It Online")
Probably possible to golf down further. Uses a comment at the end as a 'scratch space' to add extra digits. When I have to change a digit from X to Y, I change one of the Y's in the scratch to an X to compensate. Other than that this is just a function that takes an integer, using the assignment trick to return a value based on a large ternary conditional.
[Answer]
# x86 .COM, 17 bytes, controversial
```
0120 BF2001        MOV     DI,0120 (120 be the current address)
0123 B91100        MOV     CX,0011
0126 AE            SCASB
0127 7502          JNZ     012B
0129 FEC4          INC     AH
012B E2F9          LOOP    0126
012D C1E808        SHR     AX,8
0130 C3            RET
```
# 36 bytes
```
0100 BF????        MOV     DI,(an copy of this code)
0103 B91200        MOV     CX,0012
0106 AE            SCASB
0107 7503          JNZ     010C
0109 80C402        ADD     AH,02
010C E2F8          LOOP    0106
010E C1E808        SHR     AX,8
0111 C3            RET
```
[Answer]
# [APL (Dyalog Classic)](https://www.dyalog.com/), 30 bytes
```
⊢⊢⊢11-11-11-'''''''1''⊢-⍳⍳0'⍳⊢
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v8/7VHbhEddiyDI0FAXgtQhwFBdHSiq@6h3MxAZqIPorkX/H/VNBWpKUwCp4IJzDJHYQFVIPF1kmd7NSDwDJHai@n8A "APL (Dyalog Classic) – Try It Online")
## Explanation
In APL, single quotes within strings are escaped by doubling, so `'''''''1''⊢-⍳⍳0'` is the string `'''1'⊢-⍳⍳0`, which contain every character used in the program.
APL arrays are by default 1-indexed, and the index-of function, interestingly, returns `1 + max index` if the element is not found.
So, by using index-of on the string and the input returns
```
Input    Index    Count
'        1        10
1        4        7
⊢        6        5
-        7        4
⍳        8        3
0        10       1
<other>  11       0
```
As one can see, `11 - index` gives the count of the character in the program. So, the basic algorithm is
```
11-'''''''1''⊢-⍳⍳0'⍳⊢
```
The rest is bloating the character counts to allow them to fit nicely into the slots.
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 14 bytes
```
Qi"QiUè² " ²èU
```
[Try it](https://ethproductions.github.io/japt/?v=1.4.5&code=UWkiUWlV6LIgIiCy6FU=&input=J7In)
---
## Explanation
```
                   :Implicit input of character string U
  "QiUè² "         :String literal
Qi                 :Append a quotation mark
           ²       :Repeat twice
            èU     :Count the occurrences of U
```
[Answer]
# [V](https://github.com/DJMcMayhem/V), 12 bytes
```
ñéÑ~"qpxøÖa
```
[Try it online!](https://tio.run/##K/v///DGwysPT6xTKiyoOLzj8DShxP9AsWkA "V – Try It Online")
Hexdump:
```
00000000: f1e9 d17e 2271 7078 f8d6 1261            ...~"qpx...a
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 16 bytes
```
“;⁾w⁸a2”;⁾“”w⁸a2
```
[Try it online!](https://tio.run/##y0rNyan8//9RwxzrR437yh817kg0etQwF8QBigFZEKH/D3dvOdz@qGkNEB2d9HDnDCAdidDG5aCsogoA "Jelly – Try It Online")
Every character appears exactly twice.
```
“;⁾w⁸a2”;⁾“”w⁸a2
“;⁾w⁸a2”;⁾“”     the string ;⁾w⁸a2“”
            w⁸a2 return 2 if input in string
```
[Answer]
# x86, ~~42~~ 40 bytes
Here I use the same strategy as others: Create a string copy of the program with unique bytes, then return 2 in `al` if the input `al` is in the string. If we allow ourselves to read code that is actually run, we get [l4m2's solution](https://codegolf.stackexchange.com/a/162429/17360).
I got to make use of a cool string instruction `scasb`. To the best of my knowledge, there are no duplicate bytes, but this is something I'd easily screw up. Loading the string address takes 5 bytes but I'm not aware of any shorter solution (64-bit `lea` of `rip` with offset takes 6 bytes).
-2 by jumping backwards to avoid using `02` twice.
```
.section .text
.globl main
main:
        mov     $0xff, %eax
start:
        push    $20             # program length
        pop     %ecx            # counter
        mov     $str, %edi      # load string
loop:
        scasb                   # if (al == *(edi++))  
        jne     loop1           
        mov     $2, %al         # ret 2
end:    ret             
loop1:
        loop    loop            # do while (--counter)
        xor     %eax, %eax      # ret 0
        jmp     end
str:    .byte 0x6a,0x14,0x59,0xbf,0xf4,0x83,0x04,0x08 
        .byte 0xae,0x75,0x03,0xb0,0x02,0xc3,0xe2,0xf8
        .byte 0x31,0xc0,0xeb,0xf9 
```
Hexdump (of binary file format elf32-i386, as obj file unfortunately has `00` bytes for `str` address):
```
000003e0  6a 14 59 bf f4 83 04 08  ae 75 03 b0 02 c3 e2 f8  |j.Y......u......|
000003f0  31 c0 eb f9 6a 14 59 bf  f4 83 04 08 ae 75 03 b0  |1...j.Y......u..|
00000400  02 c3 e2 f8 31 c0 eb f9                           |....1...|
```
---
# x86, 256 bytes
Boring answer that is the equivalent of a giant comment. Input in `cl`, immediately returns 1 in `al`. I'll make an actual answer when I have the free time.
```
00000039  b0 01 c3 00 02 03 04 05  06 07 08 09 0a 0b 0c 0d  |................|
00000049  0e 0f 10 11 12 13 14 15  16 17 18 19 1a 1b 1c 1d  |................|
00000059  1e 1f 20 21 22 23 24 25  26 27 28 29 2a 2b 2c 2d  |.. !"#$%&'()*+,-|
00000069  2e 2f 30 31 32 33 34 35  36 37 38 39 3a 3b 3c 3d  |./0123456789:;<=|
00000079  3e 3f 40 41 42 43 44 45  46 47 48 49 4a 4b 4c 4d  |>?@ABCDEFGHIJKLM|
00000089  4e 4f 50 51 52 53 54 55  56 57 58 59 5a 5b 5c 5d  |NOPQRSTUVWXYZ[\]|
00000099  5e 5f 60 61 62 63 64 65  66 67 68 69 6a 6b 6c 6d  |^_`abcdefghijklm|
000000a9  6e 6f 70 71 72 73 74 75  76 77 78 79 7a 7b 7c 7d  |nopqrstuvwxyz{|}|
000000b9  7e 7f 80 81 82 83 84 85  86 87 88 89 8a 8b 8c 8d  |~...............|
000000c9  8e 8f 90 91 92 93 94 95  96 97 98 99 9a 9b 9c 9d  |................|
000000d9  9e 9f a0 a1 a2 a3 a4 a5  a6 a7 a8 a9 aa ab ac ad  |................|
000000e9  ae af b1 b2 b3 b4 b5 b6  b7 b8 b9 ba bb bc bd be  |................|
000000f9  bf c0 c1 c2 c4 c5 c6 c7  c8 c9 ca cb cc cd ce cf  |................|
00000109  d0 d1 d2 d3 d4 d5 d6 d7  d8 d9 da db dc dd de df  |................|
00000119  e0 e1 e2 e3 e4 e5 e6 e7  e8 e9 ea eb ec ed ee ef  |................|
00000129  f0 f1 f2 f3 f4 f5 f6 f7  f8 f9 fa fb fc fd fe ff  |................|
```
[Answer]
# [R](https://www.r-project.org/), 135 bytes
Inspired by [this Python answer](https://codegolf.stackexchange.com/a/162451/80010).
Previous versions were broken. Thanks to @Giuseppe for pointing out that `paste` was not required it saved 18 bytes or so. `lengths(regmatches(z,gregexpr(x,z)))`is from [this answer](https://stackoverflow.com/a/12427831/9670603).
```
function(x,z=rep(c("afilo2679=:","hmpu15'","nstxz","cgr","e","()",'"',","),c(2:5,7,9,15,16)))sum(lengths(regmatches(z,gregexpr(x,z))))
```
[Try it online!](https://tio.run/##pZA/a8MwEMV3fYoiD7qDK8QBJ9jEY7ZMbUYvRkh2wH@EJIPqL@@ePXQrFDrc6Qm94/10frO3980uk46veYJEa@2NAw2yta9hPl@uZV1Jkv3olrxQrKYQ08qn7jx3wwUoSUlFLJE0nKuCrlRSXlB@QcSwjDCYqYt9AG@6sY26NwFW6vhmkvN7KvtQbJkFWUsUIku1@itU8zsVPzX/51JChNlHCK1zwxdjPO7P5/3jkwYTo/GBTlW5hxCzk6w4zCK@ZZT4Sz8zx4J20qaBo@PhO2zbNw "R – Try It Online")
[Answer]
# [Pari/GP](http://pari.math.u-bordeaux.fr/), 36 bytes
```
f=(x)->#[x|c<-Vec(Str("f=",f)),x==c]
```
[Try it online!](https://tio.run/##K0gsytRNL/j/P81Wo0JT1045uqIm2UY3LDVZI7ikSEMpzVZJJ01TU6fC1jY59n9iQUFOpUaygq6dQkFRZl4JkKkE4igppGkkA1UpBKeWaMD0ArVpav4HAA "Pari/GP – Try It Online")
[Answer]
# Ruby, 48 bytes
```
->x{%q[->x{%q[].count(x.chr)*2}].count(x.chr)*2}
```
`%q[str]` is a more convenient way to write a string literal than `"str"` because it can be nested inside itself without any escaping. So I just put the entire code except for the copy inside it, then double the count.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~12~~ 10 bytes
```
“;Ṿċƈ”;Ṿċƈ
```
[Try it online!](https://tio.run/##y0rNyan8//9Rwxzrhzv3Hek@1vGoYS6M@f//sQ4A "Jelly – Try It Online")
Reads a character from STDIN.
**12 bytes**
```
Ḣ“Ḣċ;Ṿ¤”;Ṿ¤ċ
```
[Try it online!](https://tio.run/##y0rNyan8///hjkWPGuYAySPd1g937ju05FHDXAjjSPf////VgZLqAA "Jelly – Try It Online")
Using input from command line argument.
Also 12 bytes:
```
ẇ“Ṿẇ¤Ḥ”Ṿ¤Ḥ“”
```
[Try it online!](https://tio.run/##y0rNyan8///hrvZHDXMe7twHZBxa8nDHkkcNc4E8KHMOkPf//391IEcdAA "Jelly – Try It Online")
]