#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, k, l, m, n;
  string s;
  while (cin >> s) {
    string s1, s2;
    s1 = "";
    s2 = "";
    s1 += s[0];
    s1 += s[1];
    s2 += s[3];
    s2 += s[4];
    long long cnt = 0;
    while (1) {
      if (s1[0] == s2[1] && s1[1] == s2[0])
        break;
      else {
        long long t1 = (s1[0] - '0') * 10 + (s1[1] - '0');
        long long t2 = (s2[0] - '0') * 10 + (s2[1] - '0');
        t2++;
        if (t2 == 60) {
          t1++;
          t2 = 0;
        }
        if (t1 == 24) {
          t1 = 0;
        }
        int x1 = t1 / 10;
        int x2 = t1 % 10;
        s1 = "";
        s2 = "";
        char tmp = '0' + x1;
        s1 += tmp;
        tmp = '0' + x2;
        s1 += tmp;
        x1 = t2 / 10;
        x2 = t2 % 10;
        tmp = '0' + x1;
        ;
        s2 += tmp;
        tmp = '0' + x2;
        s2 += tmp;
        cnt++;
      }
    }
    cout << cnt << endl;
  }
  return 0;
}
